No tag edit access

A. Local Extrema

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given an array *a*. Some element of this array *a*_{i} is a local minimum iff it is strictly less than both of its neighbours (that is, *a*_{i} < *a*_{i - 1} and *a*_{i} < *a*_{i + 1}). Also the element can be called local maximum iff it is strictly greater than its neighbours (that is, *a*_{i} > *a*_{i - 1} and *a*_{i} > *a*_{i + 1}). Since *a*_{1} and *a*_{n} have only one neighbour each, they are neither local minima nor local maxima.

An element is called a local extremum iff it is either local maximum or local minimum. Your task is to calculate the number of local extrema in the given array.

Input

The first line contains one integer *n* (1 ≤ *n* ≤ 1000) — the number of elements in array *a*.

The second line contains *n* integers *a*_{1}, *a*_{2}, ..., *a*_{n} (1 ≤ *a*_{i} ≤ 1000) — the elements of array *a*.

Output

Print the number of local extrema in the given array.

Examples

Input

3

1 2 3

Output

0

Input

4

1 5 2 5

Output

2

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/26/2018 00:35:37 (d1).

Desktop version, switch to mobile version.

User lists

Name |
---|