There are $N$ cat towers arranged in a row from left to right, and the height of the $i$\-th tower from the left $(1\leq i\leq N)$ is $P_i$.
Here, $(P_1,P_2,\ldots,P_N)$ is a permutation of $(1,2,\ldots,N)$.
The distance between the $i$\-th tower and the $j$\-th tower from the left is defined as $\lvert i-j\rvert$.
There is one cat, initially on top of the cat tower of height $N$.
Takahashi wants to exercise this cat by repeatedly choosing and removing towers.
When Takahashi removes a tower, the cat moves as follows:
* If the cat is not on top of the tower being removed, the cat does not move.
* If the cat is on top of the tower being removed and at least one of the towers adjacent to the left or right of that tower exists, the cat moves to the tallest tower (excluding the tower being removed) among the towers that can be reached by repeatedly moving to adjacent towers starting from the tower being removed. At this time, the cat moves the distance between the tower before movement and the tower after movement (the heights of the towers before, after, and during movement do not matter).
* If the cat is on top of the tower being removed and no towers adjacent to the left or right of that tower exist, the cat jumps into Takahashi's arms, and the exercise ends here. In this case, no movement occurs.
Here, the spaces between removed towers are not filled in. That is, the towers adjacent to the $i$\-th tower from the left initially are only the $(i-1)$\-th and $(i+1)$\-th towers from the left (if they exist), and **they will never become adjacent to other towers due to the removal of other towers** afterward.
Find the maximum possible total distance the cat moves before the exercise ends.
## Constraints
* $1\leq N\leq 2\times 10^5$
* $(P_1,P_2,\ldots, P_N)$ is a permutation of $(1,2,\ldots,N)$.
* All input values are integers.
## Input
The input is given from Standard Input in the following format:
$N$
$P_1$ $P_2$ $\ldots$ $P_N$
[samples]