import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int max = 0; max 0 boolean isDecremented = false; isDecremented false for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        } {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        } int hi = sc.nextInt(); hi sc.nextInt() sc.nextInt sc if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            } max < hi max hi {
                max = hi;
                isDecremented = false;
            } max = hi max hi isDecremented = false isDecremented false if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            } (hi < max - 1) || ((hi == max - 1) && isDecremented) (hi < max - 1) hi max - 1 max 1 ((hi == max - 1) && isDecremented) (hi == max - 1) hi max - 1 max 1 isDecremented {
                System.out.println("No");
                return;
            } System.out.println("No") System.out.println System.out System System.out "No" return; if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            } hi == max - 1 hi max - 1 max 1 {
                max -= 1;
                isDecremented = true;
            } max -= 1 max 1 isDecremented = true isDecremented true System.out.println("Yes") System.out.println System.out System System.out "Yes" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
}
