#C3168. First Peak Element

    ID: 46565 Type: Default 1000ms 256MiB

First Peak Element

First Peak Element

You are given an array of integers. Your task is to find the first peak element in the array. An element is considered a peak if it is strictly greater than its adjacent neighbors. For the first and last elements, you only need to compare with the single neighbor they have.

Formally, for an element a[i] to be a peak, it must satisfy:

$$\begin{cases} a[i] > a[i+1] & \text{if } i = 0, \\ a[i] > a[i-1] & \text{if } i = n-1, \\ a[i] > a[i-1] \quad \text{and} \quad a[i] > a[i+1] & \text{if } 0 < i < n-1. \end{cases} $$

If no peak element exists in the array, output -1.

Note: If the array contains only one element, that element is considered the peak.

inputFormat

The first line of the input contains an integer n representing the number of elements in the array. The second line contains n space-separated integers which form the array.

outputFormat

Output a single integer: the first peak element found in the array. If no such element exists, output -1.

## sample
1
5
5

</p>