Easter Gift

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Wesley got an array of NN elements (a_1,a_2,,a_Na\_1, a\_2, \ldots, a\_N) for Easter, and is eager to sort it (so that a_1a_2a_Na\_1 \le a\_2 \le \ldots \le a\_N). Bored, Wesley decided to make it harder on himself by only allowing himself to swap two elements if the absolute difference between them is less than or equal to KK. Note that the elements can be anywhere; as long as their absolute difference is less than or equal to KK, Wesley can swap them.

Unfortunately, Wesley quickly realized that it might not be possible to sort the array. He then wonders: what is the minimum value of KK required to be able to sort the array?

입력

The first line contains an integer NN, the number of elements in the array (1N21051 \le N \le 2 \cdot 10^5).

The next line contains NN integers a_1,a_2,,a_Na\_1, a\_2, \ldots, a\_N, the array itself (1a_i10181 \le a\_i \le 10^{18}).

출력

Output the minimum value of KK required to be able to sort the array. If the elements are already sorted, you should output 00.