Under construction

Still being built. Things may change

Complete Road

Interview

Time limit1sMemory limit1024 MB

Summary
Given hole positions and segment length m, find the fewest damaged segments over all start offsets k from 1 to m, and list every k that reaches it.
Level

Medium5 of 10

Topics
Math, Prefix sum, Array
Solved
No attempts yet

Problem

In our beautiful homeland, roads are the pride of its citizens, especially the superhighway with the wonderfully named A1A1. Unfortunately, many tourists with their Trabants loaded with cheap pâté and cans of beer damage the road every year, so it must be repaired.

The State Institute for Road Integrity inspected the highway and marked every hole that needs repair. Repairs proceed as follows. First, starting at some point before the first damage, the road is divided into segments of equal length. Then one excavator with its crew is sent to each segment that contains damage.

Because the country has too few excavators, traffic experts must decide how to divide the road into segments of a given length so that the number of damaged segments is as small as possible.

The road has nn holes, each given as an integer that is its distance from the start of the road. The length of each segment is a given natural number mm. There is no damage in the first mm meters of the road. The first segment must start at one of the first mm meters. If the first segment starts at meter kk, then the ii-th segment starts at meter k+(i−1)⋅mk + (i - 1) \cdot m. One excavator can cover all holes from the start of a segment (inclusive) up to the start of the next segment (exclusive).

Write a program that finds the minimum number of excavators needed to repair the highway and all possible positions where the first segment can start.

Input

The first line contains the natural numbers mm and nn (1≤m,n≤100 0001 \le m, n \le 100\,000) from the problem statement.

The second line contains nn natural numbers x1,x2,…,xnx_1, x_2, \dots, x_n (m<x1<x2<⋯<xn≤2⋅109m < x_1 < x_2 < \dots < x_n \le 2 \cdot 10^9), the positions of all holes on the road.

Output

The first line contains the minimum number of excavators needed to repair the highway.

The second line contains all positions where the first segment can start, in increasing order, separated by single spaces.

Examples3

  1. Example 1

    Input
    3 5
    4 5 7 8 9
    
    Expected output
    2
    1
    
  2. Example 2

    Input
    4 3
    7 14 15
    
    Expected output
    2
    1 2 4
    
  3. Example 3

    Input
    2 10
    3 4 7 8 12 13 14 15 20 21
    
    Expected output
    7
    1 2