~/algor $ cat problems/massiv-mahalliy-maksimum
Index of the first local maximum
Easy
1000 ms
128 MB
30%
A positive integer $n$ and an array of $n$ integers ($n \ge 3$) are given. Find the index of the first local maximum — an element strictly greater than both of its neighbours (indices start from $1$; if there is none, print $0$).
Input
The first line contains a positive integer $n$. The second line contains $n$ integers separated by spaces.
Output
One integer — the index of the first local maximum or $0$.
Note
$3 \le n \le 1000$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
5 2 7 4 9 6
Output #1
2
Input #2
4 1 2 3 4
Output #2
0