Count Local Peaks
Count elements greater than both of their neighbors.
Input format
The first line contains N. The second line contains N space-separated integers.
Output format
Print how many elements are strictly greater than both of their neighbors. The first and last elements never count.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5
1 3 2 4 1Expected output
2Example 2
Input
4
1 2 3 4Expected output
0