#C3741. Find a Peak Element

    ID: 47202 Type: Default 1000ms 256MiB

Find a Peak Element

Find a Peak Element

Given an array of integers, your task is to find any peak element and return its 1-indexed position. An element at index \(i\) (1-indexed) is a peak if it satisfies the condition:

\(a_i > a_{i-1}\) and \(a_i > a_{i+1}\)

For the first and last elements, only one neighbor exists. That is, the element at the first position is a peak if \(a_1 > a_2\), and the element at the last position is a peak if \(a_n > a_{n-1}\). It is guaranteed that at least one peak exists in the array.

Note: The array is indexed starting from 1.

inputFormat

The input consists of two lines. The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers representing the elements of the array.

Example:

5
1 3 2 4 1

outputFormat

Output a single integer - the 1-indexed position of any peak element in the array.

## sample
1
5
1