Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/massiv-mahalliy-maksimum

Index of the first local maximum

Easy 1000 ms 128 MB 30%
Share

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$).

The index of a local maximum greater than both neighbours

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

Sign in to submit a solution

Signing up is free and takes a minute.