【思路】
若斜率之积为负数则该点为转折点
import java.io.*;
public class Main{
static int N = 1010;
static int a[] = new int[N];
public static void main(String args[])throws Exception{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
String [] s = bf.readLine().split(" ");
for(int i = 0; i < n ; i ++) a[i] = Integer.parseInt(s[i]);
int ans = 0;
for(int i = 1; i < n - 1; i ++)
//若斜率之积为负数则该点为转折点
if( (a[i] - a[i - 1]) * (a[ i + 1] - a[i]) < 0) ans++;
System.out.println(ans);
}
}