import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    }
} import java.util.*; util.* java public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    } main {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] P = new int[N]; P new int[N] N P[0] = sc.nextInt() P[0] P 0 sc.nextInt() sc.nextInt sc int error = 0; error 0 boolean asc = true; asc true boolean once = true; once true for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	} {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	} P[i] = sc.nextInt() P[i] P i sc.nextInt() sc.nextInt sc if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		} once && !asc && error - 1 == P[i - 1] once && !asc && error - 1 == P[i - 1] once !asc asc error - 1 == P[i - 1] error - 1 error 1 P[i - 1] P i - 1 i 1 {
    			asc = true;
				once = false;
    		} asc = true asc true once = false once false if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		} P[i] < P[i - 1] P[i] P i P[i - 1] P i - 1 i 1 {
    			error = P[i - 1];
    			asc = false;
    		} error = P[i - 1] error P[i - 1] P i - 1 i 1 asc = false asc false System.out.println(asc ? "YES" : "NO") System.out.println System.out System System.out asc ? "YES" : "NO" asc "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[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    }
} public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    }
} Main
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] P = new int[N];
    	P[0] = sc.nextInt();
    	int error = 0;
    	boolean asc = true;
    	boolean once = true;
    	for (int i = 1; i < N; i++) {
    		P[i] = sc.nextInt();
    		if (once && !asc && error - 1 == P[i - 1]) {
    			asc = true;
				once = false;
    		} else if (P[i] < P[i - 1]) {
    			error = P[i - 1];
    			asc = false;
    		}
    	}
    	System.out.println(asc ? "YES" : "NO");
    }
}