#K69912. Find the Peak Position

    ID: 33192 Type: Default 1000ms 256MiB

Find the Peak Position

Find the Peak Position

You are given an array of \(n\) integers. An element is considered a peak if it is strictly greater than its immediate neighbors. More precisely, for an index \(i\) such that \(2 \le i \le n-1\), the element \(a_i\) is a peak if \(a_i > a_{i-1}\) and \(a_i > a_{i+1}\). Your task is to find the 1-based index of any peak element in the array. If no peak exists, output -1.

inputFormat

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

outputFormat

Output a single integer representing the 1-based index of any peak element. If there is no peak, output -1.## sample

6
1 3 2 3 5 4
2