You are given an array *a*. Some element of this array *a*<sub class="lower-index">*i*</sub> is a local minimum iff it is strictly less than both of its neighbours (that is, *a*<sub class="lower-index">*i*</sub> &lt; *a*<sub class="lower-index">*i* - 1</sub> and *a*<sub class="lower-index">*i*</sub> &lt; *a*<sub class="lower-index">*i* + 1</sub>). Also the element can be called local maximum iff it is strictly greater than its neighbours (that is, *a*<sub class="lower-index">*i*</sub> &gt; *a*<sub class="lower-index">*i* - 1</sub> and *a*<sub class="lower-index">*i*</sub> &gt; *a*<sub class="lower-index">*i* + 1</sub>). Since *a*<sub class="lower-index">1</sub> and *a*<sub class="lower-index">*n*</sub> 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.
The first line contains one integer *n* (1 ≤ *n* ≤ 1000) — the number of elements in array *a*.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1000) — the elements of array *a*.
none
3
1 2 3
0
4
1 5 2 5
2
1
1
0
1
548
0
2
1 1
0
3
3 2 3
1
2
1 1000
0
3
1 2 1
1
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:ceke233
@file:day1.py
@time:2022/05/06
"""

# 一些刚毕业的常大学生去参加面试，他们排好队站成了一排，每个人都有一个能力值。如果一个人的能力值比前后两个人的能力值都高，他就会感觉自我良好，如果比前后两个人都低，那么他就会感觉很糟糕，这两种情况都会导致不正常的发挥。
# 注意：第一个人和最后一个人旁边只有一个人，所以肯定发挥正常。
# Input
# 第一行包括一个数字, n 代表这些人的总数。
# 接下来一行包括 n 个数，代表每个人的能力值。
# Output
# 输出这些人中发挥不正常的人数。
# Example
# Input
# 3
# 1 2 3
# Output
# 0
# Input
# 4
# 1 5 2 5
# Output
# 2


if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    res = 0
    for i in range(1, n - 1):
        if arr[i] > arr[i - 1] and arr[i] > arr[i + 1]:
            res += 1
        if arr[i] < arr[i - 1] and arr[i] < arr[i + 1]:
            res += 1
    print(res)

	 	   	    		   			 	 		     		