Skip to content
UPEEC

Find the Peak

Medium#searching#binary-search· solved by 0 · time limit 2.0 s

The array strictly increases up to a single peak and then strictly decreases (either part may be empty). Print the index of the peak in O(log⁡n)O(\log n).

Input

nn, then nn integers.

Output

The 0-based index of the peak.

Constraints

1≤n≤1051 \le n \le 10^5

Sample 1

Input

6
1 3 8 12 4 2

Output

3

Sample 2

Input

3
10 5 1

Output

0

Sign in or join free to run and submit your solution.