import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] low = new int[n]; low new int[n] n for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int input = sc.nextInt();
			low[i] = input;
		} {
			int input = sc.nextInt();
			low[i] = input;
		} int input = sc.nextInt(); input sc.nextInt() sc.nextInt sc low[i] = input low[i] low i input int j = 0; j 0 int count = 0; count 0 for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		} j = 1; j = 1 j 1 j < low.length j low.length low low.length j++ j++ j {
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		} {
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		} if(j+1 >= low.length){
				break;
			} j+1 >= low.length j+1 j 1 low.length low low.length {
				break;
			} break; if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			} low[j-1] < low[j] && low[j] < low[j+1] low[j-1] < low[j] low[j-1] low j-1 j 1 low[j] low j low[j] < low[j+1] low[j] low j low[j+1] low j+1 j 1 {
				count++;
			} count++ count if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			} low[j+1] < low[j] && low[j] < low[j-1] low[j+1] < low[j] low[j+1] low j+1 j 1 low[j] low j low[j] < low[j-1] low[j] low j low[j-1] low j-1 j 1 {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] low = new int[n];
		
		for(int i = 0; i < n; i++){
			int input = sc.nextInt();
			low[i] = input;
		}
		
		
		int j = 0;
		int count = 0;
		for(j = 1; j < low.length; j++){
			if(j+1 >= low.length){
				break;
			}
			if(low[j-1] < low[j] && low[j] < low[j+1]){
				count++;
			}
			else if(low[j+1] < low[j] && low[j] < low[j-1]){
				count++;
			}
		}
		System.out.println(count);
	}
}