#C9901. Counting Peaks in a Sequence

    ID: 54046 Type: Default 1000ms 256MiB

Counting Peaks in a Sequence

Counting Peaks in a Sequence

You are given a sequence of n integers. A peak in the sequence is an element that is strictly greater than its immediate neighbors. Formally, an element at index i (with 1 ≤ i ≤ n-2) is a peak if it satisfies the conditions:

$a_i > a_{i-1}$ and $a_i > a_{i+1}$

Your task is to determine the number of peaks present in the sequence.

Note: The first and last elements of the sequence are not considered, since they have only one neighbor.

inputFormat

The input is read from stdin and has the following format:

n
a1 a2 a3 ... an

Where n is the number of elements in the sequence and a1, a2, ..., an are the integers in the sequence separated by spaces.

outputFormat

Output a single integer to stdout representing the number of peaks in the sequence.

## sample
6
1 3 2 4 1 5
2