import java.util.Scanner;

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

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	}

} 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[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	}

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

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n]; h new int[n] n for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			h[i] = sc.nextInt();
		} {
			h[i] = sc.nextInt();
		} h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc sc.close() sc.close sc boolean flg = true; flg true boolean canChange = true; canChange true int oh = h[0] oh h[0] h 0 nh; nh for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		} {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		} nh = h[i] nh h[i] h i if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			} oh < nh oh nh {
				canChange = true;
			} canChange = true canChange true if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			} oh == nh + 1 && canChange oh == nh + 1 oh nh + 1 nh 1 canChange {
				canChange = false;
			} canChange = false canChange false if (oh != nh) {
				flg=false;
				break;
			} oh != nh oh nh {
				flg=false;
				break;
			} flg=false flg false break; oh = nh oh nh System.out.println(flg ? "Yes" : "No") System.out.println System.out System System.out flg ? "Yes" : "No" flg "Yes" "No" String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	}

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

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	}

} 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[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		boolean flg = true;
		boolean canChange = true;
		int oh = h[0], nh;
		for (int i = 1; i < n; i++) {
			nh = h[i];
			if (oh < nh) {
				canChange = true;
			} else if (oh == nh + 1 && canChange) {
				canChange = false;
			} else if (oh != nh) {
				flg=false;
				break;
			}
			oh = nh;
		}

		System.out.println(flg ? "Yes" : "No");
	}

}