import java.util.*;
 
public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  } main {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) int count = 0; count 0 int que = 0; que 0 int num = Integer.parseInt(in.nextLine()); num Integer.parseInt(in.nextLine()) Integer.parseInt Integer in.nextLine() in.nextLine in for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    } {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    } que <<= 5 que 5 que += Integer.parseInt(in.next()) que Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      } i > 1 i 1 {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      } int a = (que >> 10) & 31; a (que >> 10) & 31 (que >> 10) que 10 31 int b = (que >> 5) & 31; b (que >> 5) & 31 (que >> 5) que 5 31 int c = que & 31; c que & 31 que 31 if ((a - b) * (c - b) < 0) {
          count++;
        } (a - b) * (c - b) < 0 (a - b) * (c - b) (a - b) a b (c - b) c b 0 {
          count++;
        } count++ count in.close() in.close in 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 in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  }
} Main
import java.util.*;
 
public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int count = 0;
    int que = 0;
    int num = Integer.parseInt(in.nextLine());
    for(int i = 0; i < num; i++) {
      que <<= 5;
      que += Integer.parseInt(in.next());
      if (i > 1) {
        int a = (que >> 10) & 31;
        int b = (que >> 5) & 31;
        int c = que & 31;
        if ((a - b) * (c - b) < 0) {
          count++;
        }
      }
    }
    in.close();
    System.out.println(count);
  }
}