import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	}

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

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	}

} Main public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	} main {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner long[] H  = new long[N]; H new long[N] N String r="Yes"; r "Yes" boolean flg=false; flg false H[0]=Long.parseLong(scanner.next()) H[0] H 0 Long.parseLong(scanner.next()) Long.parseLong Long scanner.next() scanner.next scanner for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    } int i=1; int i=1; i 1 i<N i N i++ i++ i {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    } {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    } H[i]=Long.parseLong(scanner.next()) H[i] H i Long.parseLong(scanner.next()) Long.parseLong Long scanner.next() scanner.next scanner if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	} H[i] - H[i-1] == -1 H[i] - H[i-1] H[i] H i H[i-1] H i-1 i 1 -1 1 {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		} flg {
	    			r="No";
	    			break;
	    		} r="No" r "No" break; {
	    			flg=true;
	    		} flg=true flg true if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	} H[i] - H[i-1] <-1 H[i] - H[i-1] H[i] H i H[i-1] H i-1 i 1 -1 1 {
	    		r="No";
    			break;
	    	} r="No" r "No" break; if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	} H[i] - H[i-1] > 0 H[i] - H[i-1] H[i] H i H[i-1] H i-1 i 1 0 {
	    		flg=false;
	    	} flg=false flg false System.out.print(r) System.out.print System.out System System.out r String[] args args public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	}

} public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];

	    String r="Yes";
	    boolean flg=false;
	    H[0]=Long.parseLong(scanner.next());
	    for (int i=1; i<N; i++) {
	    	H[i]=Long.parseLong(scanner.next());
	    	if (H[i] - H[i-1] == -1) {
	    		if(flg) {
	    			r="No";
	    			break;
	    		} else {
	    			flg=true;
	    		}
	    	} else if (H[i] - H[i-1] <-1) {
	    		r="No";
    			break;
	    	} else if (H[i] - H[i-1] > 0) {
	    		flg=false;
	    	}
	    }
	    
        System.out.print(r);
	}

}