#E. AGC029 C - Lexicographic constraints

    Type: Default 2000ms 512MiB

AGC029 C - Lexicographic constraints

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Score : 700 points

Problem Statement

There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S1<S2<...<SN holds lexicographically, where Si is the i-th string from the left.

At least how many different characters are contained in S1,S2,...,SN, if the length of Si is known to be Ai?

Constraints

  • 1N2×105
  • 1Ai109
  • Ai is an integer.

Note

The strings do not necessarily consist of English alphabet; there can be arbitrarily many different characters (and the lexicographic order is defined for those characters).


Input

Input is given from Standard Input in the following format:

N
A1 A2 ... AN

Output

Print the minimum possible number of different characters contained in the strings.


Sample Input 1

3
3 2 1

Sample Output 1

2

The number of different characters contained in S1,S2,...,SN would be 3 when, for example, S1=abc, S2=bb and S3=c.

However, if we choose the strings properly, the number of different characters can be 2.


Sample Input 2

5
2 3 2 1 2

Sample Output 2

2

AGC029

Not Attended
Status
Done
Rule
IOI
Problem
8
Start at
2023-7-13 8:30
End at
2023-7-13 12:00
Duration
3.5 hour(s)
Host
Partic.
17