#CCBCHBAHAI0000021. Đếm cực đại cục bộ (Count Local Maxima)
Đếm cực đại cục bộ (Count Local Maxima)
Đếm cực đại cục bộ (Count Local Maxima)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer sequence .
An element is a strict local maximum when and
The endpoints and are never considered local maxima. If , the answer is .
Count the strict local maxima.
Input
The first line contains integer . The second line contains space-separated integers .
Output
Print one integer: the number of strict local maxima.
Subtasks
Subtask 1 (100 points): ; .
Example
Input
7
1 5 2 4 4 6 1
Output
2
Explanation
The strict local maxima are and . The adjacent equal values do not form a strict maximum.