#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 a1,a2,…,ana_1,a_2,\ldots,a_n.

An element aia_i is a strict local maximum when 2≤i≤n−12\le i\le n-1 and

ai>ai−1andai>ai+1.a_i>a_{i-1}\quad\text{and}\quad a_i>a_{i+1}.

The endpoints a1a_1 and ana_n are never considered local maxima. If n<3n<3, the answer is 00.

Count the strict local maxima.

Input

The first line contains integer nn. The second line contains nn space-separated integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print one integer: the number of strict local maxima.

Subtasks

Subtask 1 (100 points): 1≤n≤2⋅1051\le n\le 2\cdot 10^5; ∣ai∣≤109|a_i|\le 10^9.

Example

Input

7
1 5 2 4 4 6 1

Output

2

Explanation

The strict local maxima are a2=5a_2=5 and a6=6a_6=6. The adjacent equal values 4,44,4 do not form a strict maximum.