Under construction

Still being built. Things may change

Street Development

Time limit1sMemory limit2048 MB

Summary
Given n robot positions on the street [0, L], find the minimum battery capacity P that lets robots merge all collected information into one robot.
Level

Medium6 of 10

Topics
Binary search, Greedy, Array
Solved
No attempts yet

Problem

ICPC street is still an undeveloped area, and a large-scale development plan is scheduled to start soon. Before development begins, nn remote-controlled robots collect information from nn important points along the street, one robot per point. The goal is to combine all the collected information into a single robot so that the most efficient development approach can be found.

The street is the interval [0,L][0, L] for a positive integer LL. The important points p1,p2,…,pnp_1, p_2, \dots, p_n are integers on the interval, including both endpoints. That is, p1=0p_1 = 0 and pn=Lp_n = L. At the start, each robot stands at one important point and already has that point's information. There is exactly one robot per point, so nn is also the number of robots. 2≤n≤L+12 \le n \le L + 1.

  1. Robots can move left or right freely. Each unit of distance traveled costs 1 unit of battery, in either direction. All robots have the same battery capacity, an integer PP, and move only in integer units of distance.
  2. When two or more robots meet at an integer position, they combine each other's information. For example, if a robot holding the information of p1p_1 and p2p_2 meets a robot holding the information of p3p_3 and p4p_4, both robots then have the information of p1p_1, p2p_2, p3p_3, and p4p_4.
  3. Battery is used only for movement. Changing direction and combining information cost no battery.
  4. After all movements, at least one robot must have the information of all of p1,p2,…,pnp_1, p_2, \dots, p_n.

The figure shows an example with L=10L = 10 and n=4n = 4. Robots R1, R2, R3, and R4 start at p1=0p_1 = 0, p2=3p_2 = 3, p3=7p_3 = 7, and p4=10p_4 = 10. With battery capacity P=3P = 3, the following steps can be performed. Robot 1 moves to p2p_2, and robots 1 and 2 combine their information. Robot 4 moves to p3p_3, and robots 3 and 4 combine their information. Robot 2 moves 2 units to the right, robot 3 moves 2 units to the left, and they combine their information at position 5. Afterward, robots 2 and 3 have the information of all four points.

Input

The first line contains two positive integers LL and nn (1≤L≤1061 \le L \le 10^6, 2≤n≤L+12 \le n \le L + 1). The second line contains nn distinct integers between 00 and LL in increasing order, which are the initial positions of the robots. The first integer is 00 and the last one is LL.

Output

Print one line containing a single integer: the minimum battery capacity PP that lets at least one robot have the information of all important points.

Examples3

  1. Example 1

    Input
    10 4
    0 3 7 10
    
    Expected output
    3
    
  2. Example 2

    Input
    100 5
    0 97 98 99 100
    
    Expected output
    49
    
  3. Example 3

    Input
    1 2
    0 1
    
    Expected output
    1