Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

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-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/14/2019 05:25:09 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|