import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
} 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[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] P = new int[N]; P new int[N] N for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            P[i] = sc.nextInt();
        } {
            P[i] = sc.nextInt();
        } P[i] = sc.nextInt() P[i] P i sc.nextInt() sc.nextInt sc sc.close() sc.close sc System.out.println(OrdinaryNumber(N, P, 1)) System.out.println System.out System System.out OrdinaryNumber(N, P, 1) OrdinaryNumber N P 1 String[] args args public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    } OrdinaryNumber {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    } if (N - 1 <= index) {
            return 0;
        } N - 1 <= index N - 1 N 1 index {
            return 0;
        } return 0; 0 if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        } (P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1]) (P[index - 1] < P[index] && P[index] < P[index + 1]) P[index - 1] < P[index] P[index - 1] P index - 1 index 1 P[index] P index P[index] < P[index + 1] P[index] P index P[index + 1] P index + 1 index 1 (P[index + 1] < P[index] && P[index] < P[index - 1]) P[index + 1] < P[index] P[index + 1] P index + 1 index 1 P[index] P index P[index] < P[index - 1] P[index] P index P[index - 1] P index - 1 index 1 {
            return 1 + OrdinaryNumber(N, P, index + 1);
        } return 1 + OrdinaryNumber(N, P, index + 1); 1 + OrdinaryNumber(N, P, index + 1) 1 OrdinaryNumber(N, P, index + 1) OrdinaryNumber N P index + 1 index 1 return OrdinaryNumber(N, P, index + 1); OrdinaryNumber(N, P, index + 1) OrdinaryNumber N P index + 1 index 1 int N N int[] P P int index index public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
}
