Bessie likes playing games on her cell phone.
The game starts with a sequence of positive integers, each in the range . In one move, Bessie can choose two adjacent numbers with equal values and replace them with a single number whose value is one greater. For example, she can replace two adjacent s with an .
Bessie's goal is to maximize the value of the largest number remaining in the sequence at the end of the game. Please help Bessie achieve the highest score possible!
The first line contains an integer n~(2 \le n \le 248). The next lines each contain one integer representing the corresponding number in the initial sequence.
Print the largest integer Bessie can generate.
In the example shown here, Bessie first merges the second and third s, obtaining the sequence . She then merges the two s to obtain a . Note that it is not optimal to merge the first two s.
Example 1