import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
} Main public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] array = new int[20]; array new int[20] 20 for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    } int i = 0 ; int i = 0 ; i 0 i < N i N i ++ i ++ i {
      array[i] = sc.nextInt();
    } {
      array[i] = sc.nextInt();
    } array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc boolean flag = false; flag false int cnt = 0; cnt 0 for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    } int i = 1 ; int i = 1 ; i 1 i < N-1 i N-1 N 1 i++ i++ i {
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    } {
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    } int a = array[i-1]; a array[i-1] array i-1 i 1 int b = array[i]; b array[i] array i int c = array[i+1]; c array[i+1] array i+1 i 1 if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      } a<b && b<c a<b a b b<c b c {
        cnt++;
      } cnt++ cnt if(a>b && b>c){
        cnt++;
      } a>b && b>c a>b a b b>c b c {
        cnt++;
      } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
} public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[20];
    
    for(int i = 0 ; i < N ; i ++){
      array[i] = sc.nextInt();
    }
    
    boolean flag = false;
    int cnt = 0;
    
    for(int i = 1 ; i < N-1; i++){
      int a = array[i-1];
      int b = array[i];
      int c = array[i+1];
      if(a<b && b<c){
        cnt++;
      }else if(a>b && b>c){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}