import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int [] in = new int [a]; in new int [a] a for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            } int i=0; int i=0; i 0 i<a i a i++ i++ i {
                             in[i] = sc.nextInt();
                            } {
                             in[i] = sc.nextInt();
                            } in[i] = sc.nextInt() in[i] in i sc.nextInt() sc.nextInt sc int b = 0; b 0 for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            } int i=0; int i=0; i 0 i<a-2 i a-2 a 2 i++ i++ i {if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            } {if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            } if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 } (in[i+1]-in[i])*(in[i+1]-in[i+2])<0 (in[i+1]-in[i])*(in[i+1]-in[i+2]) (in[i+1]-in[i]) in[i+1] in i+1 i 1 in[i] in i (in[i+1]-in[i+2]) in[i+1] in i+1 i 1 in[i+2] in i+2 i 2 0 {b++;
                                                 } b++ b System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
       
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		int b = 0;
        for(int i=0;i<a-2;i++){if((in[i+1]-in[i])*(in[i+1]-in[i+2])<0){b++;
                                                 }
                            }
       
		System.out.println(b);
	}
}
