Icicles

No attempts yetTime limit1sMemory limit128 MB

Problem

Under the eaves of JOI's house in Canada, a fine row of icicles has formed. Curious about them, JOI decides to take a closer look.

There are $N$ icicles ($2 \le N \le 100000$) hanging in a straight line under the eaves. The $i$-th icicle ($1 \le i \le N$) hangs at the position $i$ cm from the left end, and its initial length is $a_i$ cm (where $a_i$ is a positive integer). The icicles grow according to the following rules.

  • The $i$-th icicle grows by $1$ cm each hour if and only if it is strictly longer than both the $(i-1)$-th and the $(i+1)$-th icicles. For the two icicles at the ends, only the single existing neighbor is considered: the $1$st icicle grows while it is longer than the $2$nd, and the $N$-th icicle grows while it is longer than the $(N-1)$-th.
  • The moment an icicle reaches a length of $L$ cm ($2 \le L \le 50000$), it snaps off at the base. A broken icicle is thereafter treated as an icicle of length $0$ cm.

Initially, every two adjacent icicles have different lengths. Under this condition, after enough time all $N$ icicles will have snapped off and become $0$ cm long. Compute the number of hours it takes until every icicle has broken.

Input

The first line contains two integers $N$ and $L$, the number of icicles and the breaking length, separated by a space. Each of the next $N$ lines contains one integer $a_i$ ($1 \le a_i < L$), the initial length of the $i$-th icicle.

Output

Print a single integer: the number of hours until all icicles have broken.

Hint

Consider icicles with initial lengths $4, 2, 3, 5$ and breaking length $L = 6$. The $1$st, $2$nd, $3$rd, and $4$th icicles break after $2$, $8$, $4$, and $1$ hours respectively. Hence all icicles have broken after $8$ hours, so the answer is $8$.