import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

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

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

} Main public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	} main {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	} java.util.Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int masu = scan.nextInt(); masu scan.nextInt() scan.nextInt scan long[] height = new long[masu]; height new long[masu] masu boolean flg = false; flg false long max = 0; max 0 for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		} int i=0; int i=0; i 0 i<masu i masu i++ i++ i {
			height[i] = scan.nextLong();
		} {
			height[i] = scan.nextLong();
		} height[i] = scan.nextLong() height[i] height i scan.nextLong() scan.nextLong scan for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		} int i=0; int i=0; i 0 i<masu-1 i masu-1 masu 1 i++ i++ i {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		} {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		} max = Math.max(max,height[i]) max Math.max(max,height[i]) Math.max Math max height[i] height i if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			} height[i] > height[i+1] height[i] height i height[i+1] height i+1 i 1 {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			} if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				} height[i]-1 > height[i+1] || height[i]-1 !=max-1 height[i]-1 > height[i+1] height[i]-1 height[i] height i 1 height[i+1] height i+1 i 1 height[i]-1 !=max-1 height[i]-1 height[i] height i 1 max-1 max 1 {
				flg = true;
				} flg = true flg true System.out.println(flg?"No":"Yes") System.out.println System.out System System.out flg?"No":"Yes" flg "No" "Yes" scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

} public class Main {

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

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

	public static void main(String[] args) {

		java.util.Scanner scan = new Scanner(System.in);

		int masu = scan.nextInt();
		long[] height = new long[masu];
		boolean flg = false;
		long max = 0;

		for(int i=0;i<masu;i++) {
			height[i] = scan.nextLong();
		}

		for(int i=0;i<masu-1;i++) {
			max = Math.max(max,height[i]);
			if(height[i] > height[i+1]) {
				if(height[i]-1 > height[i+1] || height[i]-1 !=max-1) {
				flg = true;
				}
			}
		}
		System.out.println(flg?"No":"Yes");
		scan.close();
	}

}
