import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	}

} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	} main {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn long max = 0; max 0 long[]h = new long[n]; h new long[n] n for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = stdIn.nextLong();
		} {
			h[i] = stdIn.nextLong();
		} h[i] = stdIn.nextLong() h[i] h i stdIn.nextLong() stdIn.nextLong stdIn boolean flag = false; flag false for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		} int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		} {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		} max = Math.max(max, h[i]) max Math.max(max, h[i]) Math.max Math max h[i] h i if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			} h[i] > h[i+1] h[i] h i h[i+1] h i+1 i 1 {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			} if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				} h[i]-1 > h[i+1] || h[i]-1 != max - 1 h[i]-1 > h[i+1] h[i]-1 h[i] h i 1 h[i+1] h i+1 i 1 h[i]-1 != max - 1 h[i]-1 h[i] h i 1 max - 1 max 1 {
					flag = true;
				} flag = true flag true if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		} flag {
			System.out.println("No");
		} System.out.println("No") System.out.println System.out System System.out "No" {
			System.out.println("Yes");
		} 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 stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	}

} public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	}

} Main
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long max = 0;
		
		long[]h = new long[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = stdIn.nextLong();
		}
		
		boolean flag = false;
		
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, h[i]);
			
			if(h[i] > h[i+1]) {
				if(h[i]-1 > h[i+1] || h[i]-1 != max - 1) {
					flag = true;
				}
			}
		}
		
		if(flag) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
				
	}

}
