import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int Ans = 0;
      int flg = 0;
      int N = sc.nextInt();
      long[] a = new long[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      }
      
      for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      }
      if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      }
      
  }  
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int Ans = 0;
      int flg = 0;
      int N = sc.nextInt();
      long[] a = new long[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      }
      
      for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      }
      if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      }
      
  }  
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int Ans = 0;
      int flg = 0;
      int N = sc.nextInt();
      long[] a = new long[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      }
      
      for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      }
      if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      }
      
  } main {
      Scanner sc = new Scanner(System.in);
      int Ans = 0;
      int flg = 0;
      int N = sc.nextInt();
      long[] a = new long[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      }
      
      for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      }
      if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      }
      
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int Ans = 0; Ans 0 int flg = 0; flg 0 int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] a = new long[N]; a new long[N] N for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      } int i=0 ; int i=0 ; i 0 i<N i N i++ i++ i {
          a[i] = sc.nextLong();
      } {
          a[i] = sc.nextLong();
      } a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      } int i=1; int i=1; i 1 i<N i N i++ i++ i {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      } {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      } if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  } a[i-1]>a[i] a[i-1] a i-1 i 1 a[i] a i {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  } a[i-1]-1==a[i] a[i-1]-1 a[i-1] a i-1 i 1 1 a[i] a i {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  } flg==0 flg 0 {
    				  flg = 1;
    			  } flg = 1 flg 1 {
    				  Ans = 1;
    				  break;
    			  } Ans = 1 Ans 1 break; {
    			  Ans = 1;
    			  break;
    		  } Ans = 1 Ans 1 break; if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  } a[i-1]==a[i] a[i-1] a i-1 i 1 a[i] a i {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  } if(flg == 1) {
    			  flg = 1;
    		  } flg == 1 flg 1 {
    			  flg = 1;
    		  } flg = 1 flg 1 {
    		  flg = 0;
    	  } flg = 0 flg 0 if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      } Ans == 0 Ans 0 {
    	  System.out.println("Yes");
      } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
    	  System.out.println("No");
      } System.out.println("No") System.out.println System.out System System.out "No" String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int Ans = 0;
      int flg = 0;
      int N = sc.nextInt();
      long[] a = new long[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextLong();
      }
      
      for(int i=1; i<N; i++) {
    	  if(a[i-1]>a[i]) {
    		  if(a[i-1]-1==a[i]) {
    			  if (flg==0) {
    				  flg = 1;
    			  } else {
    				  Ans = 1;
    				  break;
    			  }
    		  } else {
    			  Ans = 1;
    			  break;
    		  }
    	  } else if (a[i-1]==a[i]) {
    		  if(flg == 1) {
    			  flg = 1;
    		  }
    	  }
    	  
    	  else {
    		  flg = 0;
    	  }
      }
      if (Ans == 0) {
    	  System.out.println("Yes");
      } else {
    	  System.out.println("No");
      }
      
  }  
}