#ARC120E. [ARC120E] 1D Party

[ARC120E] 1D Party

Score : 700700 points

Problem Statement

There are NN people, Person 11 through Person NN, standing on a number line. Person ii is now at coordinate AiA_i on the number line. Here, A1<A2<A3<<ANA_1 < A_2 < A_3 < \dots < A_N and all AiA_i are even numbers.

We will now hold a party for kk seconds. During the party, each person can freely move on the number line at a speed of at most 11 per second. (It is also allowed to move in the negative direction within the speed limit.) The people request that the following condition be satisfied for every integer ii such that 1i<N1 \le i \lt N:

  • there is at least one moment during the party (including the moment it ends) when Person ii and Person i+1i + 1 are at the same coordinate.

Find the minimum kk for which there is a strategy that the people can take to satisfy all the conditions. We can prove that the answer is an integer under the Constraints of this problem.

Constraints

  • 2N2×1052 \le N \le 2 \times 10^5
  • 0Ai1090 \le A_i \le 10^9
  • A1<A2<A3<<ANA_1 < A_2 < A_3 < \dots < A_N
  • AiA_i is an even number.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 A3A_3 \dots ANA_N

Output

Print the answer as an integer.

3
0 6 10
5

During the party lasting 55 seconds, each person should move as follows:

  • Person 11: always moves in the positive direction at a speed of 11.
  • Person 22: moves in the positive direction at a speed of 11 during the first 22 seconds, then in the negative direction at a speed of 11 during the remaining 33 seconds.
  • Person 33: always moves in the negative direction at a speed of 11.

If they move in this way, Person 22 and Person 33 will be at the same coordinate exactly 22 seconds after the beginning, and Person 11 and Person 22 will be at the same coordinate at the end of the party. Thus, they can satisfy all the conditions for k=5k = 5. For smaller kk, there is no strategy to satisfy all of them.

5
0 2 4 6 8
3

During the party lasting 33 seconds, each person should, for example, move as follows:

  • Person 11: always moves in the positive direction at a speed of 11.
  • Person 22: moves in the positive direction at a speed of 11 during the first 22 seconds, then in the negative direction at a speed of 11 during the remaining 11 second.
  • Person 33: does not move at all.
  • Person 44: moves in the negative direction at a speed of 11 during the first 22 seconds, then in the positive direction at a speed of 11 during the remaining 11 second.
  • Person 55: always moves in the negative direction at a speed of 11.
10
0 2 4 6 8 92 94 96 98 100
44