#K92852. Highest Peak
Highest Peak
Highest Peak
You are given an array of integers. Your task is to find the highest peak in the array. An element is considered a peak if it is strictly greater than its immediate neighbors. For the first and last elements, since they have only one neighbor, they are considered a peak if they are greater than that single neighbor.
For example, given the array [1, 2, 3, 1, 5, 6, 4, 2], the peaks are 3 (at index 2) and 6 (at index 5), so the answer is 6. If no peak exists, return -1. It is guaranteed that under the given constraints, the array will always have at least one peak.
The input is read from the standard input and the result should be printed to the standard output.
inputFormat
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 array.
outputFormat
Output a single integer representing the highest peak found in the array.
## sample8
1 2 3 1 5 6 4 2
6