#CCBCHBAHAI0000022. Đếm cực tiểu cục bộ (Count Local Minima)

Đếm cực tiểu cục bộ (Count Local Minima)

Đếm cực tiểu cục bộ (Count Local Minima)

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 minimum 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 minima. If n<3n<3, the answer is 00.

Count the strict local minima.

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 minima.

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
5 1 4 2 6 0 3

Output

3

Explanation

Positions i=2,4,6i=2,4,6 contain 1,2,01,2,0 respectively, each strictly smaller than both neighbors.