import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	} main {
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int buildcnt = sc.nextInt(); buildcnt sc.nextInt() sc.nextInt sc int hights[]= new int[buildcnt]; hights new int[buildcnt] buildcnt boolean reach =false; reach false String answer = "Yes"; answer "Yes" for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        } int i=0 ; int i=0 ; i 0 i<buildcnt i buildcnt i++ i++ i {
         hights[i]=sc.nextInt(); 
        } {
         hights[i]=sc.nextInt(); 
        } hights[i]=sc.nextInt() hights[i] hights i sc.nextInt() sc.nextInt sc for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      } int i=buildcnt-1 ; int i=buildcnt-1 ; i buildcnt-1 buildcnt 1 i>0 i 0 i-- i-- i {
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      } {
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      } if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          } hights[i-1] - hights[i] >1 hights[i-1] - hights[i] hights[i-1] hights i-1 i 1 hights[i] hights i 1 {
            answer = "No";
            break;
          } answer = "No" answer "No" break; if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          } hights[i-1]-hights[i]==1 && !reach hights[i-1]-hights[i]==1 hights[i-1]-hights[i] hights[i-1] hights i-1 i 1 hights[i] hights i 1 !reach reach {
            reach=true;
          } reach=true reach true if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          } hights[i-1]-hights[i]==1 && reach hights[i-1]-hights[i]==1 hights[i-1]-hights[i] hights[i-1] hights i-1 i 1 hights[i] hights i 1 reach {
            answer="No";
            break;
          } answer="No" answer "No" break; if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          } hights[i-1]-hights[i]==0 && reach hights[i-1]-hights[i]==0 hights[i-1]-hights[i] hights[i-1] hights i-1 i 1 hights[i] hights i 0 reach {
            reach=true;
          } reach=true reach true {
            reach=false;
          } reach=false reach false System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int buildcnt = sc.nextInt();
        int hights[]= new int[buildcnt];
            boolean reach =false;
      String answer = "Yes";
        for(int i=0 ; i<buildcnt ; i++){
         hights[i]=sc.nextInt(); 
        }
//      List<Integer> numlist = new ArrayList<Integer>();
//      while(sc.hasnext()){
  //      numlist.add(sc.nextInt());
    //  }
      for(int i=buildcnt-1 ; i>0 ; i--){
          if(hights[i-1] - hights[i] >1 ){
            answer = "No";
            break;
          }else if(hights[i-1]-hights[i]==1 && !reach){
            reach=true;
          }else if(hights[i-1]-hights[i]==1 && reach){
            answer="No";
            break;
          }else if(hights[i-1]-hights[i]==0 && reach){
            reach=true;
          }else{
            reach=false;
          }
      }

//      int now = sc.nextInt();
//      while(sc.hasNext()){
//       int next = sc.nextInt();
       //今-次が2以上ならNG
 //      if(now - next >= 2){
//         answer="NO";
  //       break;
  //     }else if(now - next == 1){
        
  //       if(reach == true){
  //        answer ="NO";
  //         break;
  //       }else{
  //         reach=true;
  //         now = next;
  //       }
  //     }else{
  //      now = next;
  //      reach=false;
  //     }
   //   }
        // 出力 
		System.out.println(answer);
//      		System.out.println(buildcnt);
//      for(int i=0;i<buildcnt;i++){
//      		System.out.println(hights[i]);
//      }
	}
}
