import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long[] arr = new long[n]; arr new long[n] n long[] arr1 = new long[n]; arr1 new long[n] n for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    } {
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    } arr[i]=sc.nextLong() arr[i] arr i sc.nextLong() sc.nextLong sc arr1[i]=arr[i] arr1[i] arr1 i arr[i] arr i Arrays.sort(arr1) Arrays.sort Arrays arr1 int flag=0; flag 0 for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    } {
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    } if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      } Math.abs(arr[i]-arr1[i])>1 Math.abs(arr[i]-arr1[i]) Math.abs Math arr[i]-arr1[i] arr[i] arr i arr1[i] arr1 i 1 {
        flag=1;
        break;
      } flag=1 flag 1 break; if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    } flag==1 flag 1 {
      System.out.println("No");
    } System.out.println("No") System.out.println System.out System System.out "No" {
      System.out.println("Yes");
    } System.out.println("Yes") System.out.println System.out System System.out "Yes" String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] arr = new long[n];
    long[] arr1 = new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextLong();
      arr1[i]=arr[i];
    }
    Arrays.sort(arr1);
    int flag=0;
    for(int i=0;i<n;i++){
      if(Math.abs(arr[i]-arr1[i])>1){
        flag=1;
        break;
      }
    }
    if(flag==1){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
   
  }
}