#74Medium
Smallest local maximum
Time: 1 s · Memory: 256 MB
- Arrays
Statement
A local maximum of an array is an element strictly greater than both of its neighbours. The first and the last elements have only one neighbour, so they are not local maxima.
You are given an array of numbers. Find the smallest of its local maxima.
Input format
The first line contains (). The second line contains integers (). The array has at least one local maximum.
Output format
A single number — the smallest local maximum.
Examples
Input
8 1 3 2 4 6 5 9 1
Output
3
Input
5 1 2 2 3 1
Output
3
Note
For check . In the first example the local maxima are , , — the smallest is . In the second, is a flat spot: is not strictly greater than its neighbour, and the only local maximum is .
