#K3651. Find Peak Element

    ID: 25770 Type: Default 1000ms 256MiB

Find Peak Element

Find Peak Element

You are given a list of integers. A peak element is an element that is strictly greater than its neighbors. For the corner elements, we only consider one neighbor. Formally, an element ai is a peak if it satisfies:

$$ \text{if } 1 < i a_{i-1} \text{ and } a_i > a_{i+1} $$

For i = 0 (first element) or i = n-1 (last element), the condition is checked with the single adjacent element.

It is guaranteed that a peak element always exists. Your task is to find any one peak element from the list.

inputFormat

The input is read from standard input and consists of two lines.

  • The first line contains an integer n representing the number of elements in the list.
  • The second line contains n space-separated integers, representing the elements of the list.

outputFormat

Output a single integer which is any peak element from the list. The result should be printed to standard output.

## sample
1
1
1