  import java.util.*;
  public class Main {
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          } 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 a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          } Main public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          } main {
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a a b b c; c a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc c = sc.nextInt() c sc.nextInt() sc.nextInt sc int count = 0; count 0 if((a<b&&b<c)||(c<b&&b<a)){
          count ++;} (a<b&&b<c)||(c<b&&b<a) (a<b&&b<c) a<b a b b<c b c (c<b&&b<a) c<b c b b<a b a {
          count ++;} count ++ count for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          } int i=0; int i=0; i 0 i<n-3 i n-3 n 3 i++ i++ i {
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          } {
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          } a = b a b b = c b c c = sc.nextInt() c sc.nextInt() sc.nextInt sc if((a<b&&b<c)||(c<b&&b<a)){
          count ++;} (a<b&&b<c)||(c<b&&b<a) (a<b&&b<c) a<b a b b<c b c (c<b&&b<a) c<b c b b<a b a {
          count ++;} count ++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          } public class Main {
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          } Main
  import java.util.*;
  public class Main {
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          }