import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	}
} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	} try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		} {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] cells = new int[n]; cells new int[n] n for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
				cells[i] = sc.nextInt();
			} {
				cells[i] = sc.nextInt();
			} cells[i] = sc.nextInt() cells[i] cells i sc.nextInt() sc.nextInt sc int rightHeight = cells[n-1]; rightHeight cells[n-1] cells n-1 n 1 for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			} int i = 1 ; int i = 1 ; i 1 i < n i n i++ i++ i {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			} {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			} int current = cells[n-i-1]; current cells[n-i-1] cells n-i-1 n-i-1 n i 1 if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				} current == rightHeight ||  current - 1 == rightHeight current == rightHeight current rightHeight current - 1 == rightHeight current - 1 current 1 rightHeight {
					//ok
				} if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				} current < rightHeight current rightHeight {
					rightHeight = current;
				} rightHeight = current rightHeight current {
					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){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	}
} public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			int[] cells = new int[n];

			for(int i = 0 ; i < n ; i++ ) {
				cells[i] = sc.nextInt();
			}
			
			int rightHeight = cells[n-1];
			for(int i = 1 ; i < n ; i++ ) {
				//right to left
				int current = cells[n-i-1];
				if ( current == rightHeight ||  current - 1 == rightHeight ) {
					//ok
				}
				else if ( current < rightHeight ) {
					rightHeight = current;
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			System.out.println("Yes");
		}
	}
}
