#K4861. Count Peak Time Slots

    ID: 28459 Type: Default 1000ms 256MiB

Count Peak Time Slots

Count Peak Time Slots

You are given an integer T representing the total number of time slots and a list A of T integers representing the number of login attempts in each time slot.

A time slot i (with 0-indexing, where 0 ≤ i < T) is defined as a peak if it is strictly greater than both its immediate neighbors. In formal terms, for a time slot i (with 1 ≤ i ≤ T-2), it is a peak if:

$$A_{i} > A_{i-1} \quad\text{and}\quad A_{i} > A_{i+1}.$$

Your task is to count and output the number of peak time slots. Note that the first and last slots cannot be peaks because they have only one neighbor.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains an integer T — the total number of time slots.
  • The second line contains T space-separated integers, where the i-th integer represents the number of login attempts in the i-th time slot.

outputFormat

Output a single integer to stdout representing the number of peak time slots.

## sample
5
1 3 2 4 2
2

</p>