import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
} 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();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        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 ArrayList<Integer> hl = new ArrayList<>(); hl new ArrayList<>() int prev = Integer.MAX_VALUE; prev Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            hl.add(sc.nextInt());
        } {
            hl.add(sc.nextInt());
        } hl.add(sc.nextInt()) hl.add hl sc.nextInt() sc.nextInt sc Collections.reverse(hl) Collections.reverse Collections hl for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        } {
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        } int now = hl.get(i); now hl.get(i) hl.get hl i if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            } prev >= now prev now {
                prev = now;
            } prev = now prev now if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            } prev+1 == now prev+1 prev 1 now {
                continue;
            } continue; {
                System.out.println("No");
                return;
            } System.out.println("No") System.out.println System.out System System.out "No" return; 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) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
} 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();
        ArrayList<Integer> hl = new ArrayList<>();
        int prev = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            hl.add(sc.nextInt());
        }
        Collections.reverse(hl);
        for(int i = 0; i < n; i++){
            int now = hl.get(i);
            if(prev >= now){
                prev = now;
            }else if(prev+1 == now){
                continue;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}
