#C6915. Count Mountain Peaks

    ID: 50728 Type: Default 1000ms 256MiB

Count Mountain Peaks

Count Mountain Peaks

You are given an array of integers representing the heights of a mountain range. Your task is to count the number of mountain peaks in the array. A mountain peak is defined as an element that is strictly greater than its immediate neighbors. Note that the first and the last element in the array cannot be considered as peaks.

More formally, an element hi (for 1 \leq i \leq n-2) is a peak if and only if:

\( h_i > h_{i-1} \) and \( h_i > h_{i+1} \).

Your program should read the input from stdin and write the answer to stdout.

inputFormat

The first line contains a single integer n (the number of elements in the array). The second line contains n space-separated integers representing the heights.

outputFormat

Output a single integer representing the number of mountain peaks in the array.

## sample
4
1 2 3 4
0