I. IMO Problem
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

The section below is from IMO 2023 problem 5.

Let $$$n$$$ be a positive integer. A Japanese triangle consists of $$$1 + 2 + \cdots + n$$$ circles arranged in an equilateral triangular shape such that for each $$$i = 1, 2, \ldots , n$$$, the (i)-th row contains exactly $$$i$$$ circles, exactly one of which is coloured red. A ninja path in a Japanese triangle is a sequence of $$$n$$$ circles obtained by starting in the top row, then repeatedly going from a circle to one of the two circles immediately below it and finishing in the bottom row. Here is an example of a Japanese triangle with $$$n = 6$$$, along with a ninja path in that triangle containing two red circles.

Note that this is not the ninja path containing maximum red circles.

Now, you are given a configuration of a Japanese triangle, please find the ninja path containing maximum red circles.

Input

The first line of the input contains an integer $$$n$$$. The second line of the input contains $$$n$$$ integers $$$a_i$$$, seperated by space. $$$a_i = x$$$ means the $$$x$$$-th circle of the $$$i$$$-th row is red.

  • $$$1 \leq n \leq 10^6$$$
  • $$$1 \leq a_i \leq i\ \forall 1 \leq i \leq n$$$.
Output

Output a single line, the maximum number.

Examples
Input
6
1 1 3 3 4 1
Output
4
Input
6
1 1 1 3 5 6
Output
3