import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String[] hs = br.readLine().split(" "); hs br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] he = new int[n]; he new int[n] n for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			he[i] = Integer.parseInt(hs[i]);
		} {
			he[i] = Integer.parseInt(hs[i]);
		} he[i] = Integer.parseInt(hs[i]) he[i] he i Integer.parseInt(hs[i]) Integer.parseInt Integer hs[i] hs i int max = he[0]; max he[0] he 0 boolean stop = false; stop false for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		} int i = 0; int i = 0; i 0 i < n-1 && !stop i < n-1 i n-1 n 1 !stop stop i++ i++ i {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		} {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		} if(max < he[i]) {
				max=he[i];
			} max < he[i] max he[i] he i {
				max=he[i];
			} max=he[i] max he[i] he i if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			} he[i] <= he[i+1] he[i] he i he[i+1] he i+1 i 1 {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} if(max == he[i]) {
					max--;
				} max == he[i] max he[i] he i {
					max--;
				} max-- max he[i]-- he[i] he i {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			} if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				} he[i] - 1 > he[i+1] || he[i] < max he[i] - 1 > he[i+1] he[i] - 1 he[i] he i 1 he[i+1] he i+1 i 1 he[i] < max he[i] he i max {
					stop = true;
					System.out.println("No");
				} stop = true stop true System.out.println("No") System.out.println System.out System System.out "No" {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				} he[i]-- he[i] he i if(max == he[i]) {
						max--;
					} max == he[i] max he[i] he i {
						max--;
					} max-- max if(!stop) System.out.println("Yes"); !stop stop System.out.println("Yes") System.out.println System.out System System.out "Yes" br.close() br.close br String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		int[] he = new int[n];			
		for (int i = 0; i < n; i++) {
			he[i] = Integer.parseInt(hs[i]);
		}
		int max = he[0];
		boolean stop = false;
		for (int i = 0; i < n-1 && !stop; i++) {
			if(max < he[i]) {
				max=he[i];
			}
			if(he[i] <= he[i+1]) {
				if(max == he[i]) {
					max--;
				}
				he[i]--;
			} else {
				if(he[i] - 1 > he[i+1] || he[i] < max) {
					stop = true;
					System.out.println("No");
				} else {
					he[i]--;
					if(max == he[i]) {
						max--;
					}
				}
			}
			//System.out.println(Arrays.toString(he));
			//System.out.println(max);
		}
		if(!stop) System.out.println("Yes");
		//System.out.println(Arrays.toString(he));
		br.close();
	}

}
