All problems

Marking Each Data Point

easyPythonMatplotlibLine Chart

A pressure trace from a test rig is charted as a line with a dot at every reading, so the reader can see where the actual measurements are rather than guessing from the line between them. The engineers then want a count of the trace's peaks. A reading counts as a peak when it is strictly higher than the reading before it and strictly higher than the reading after it. The very first and very last readings can never be peaks, because each has only one neighbour and there is nothing to compare on the other side.

Task: Print how many readings are peaks.

Input

The first line holds an integer n, the number of readings. Each of the next n lines holds one reading, in the order they were taken.

Output

One line holding the count of peaks, as a plain integer.

Example:

Input:
5
1
5
2
8
3

Output:
2

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…