import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
} Main public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    } main {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            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 int arr[] = new int[n]; arr new int[n] n boolean found = false; found false for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int max = 0; max 0 if(n == 1){ System.out.println("Yes");} n == 1 n 1 { System.out.println("Yes");} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    } n != 1 n 1 {for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    } for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            max = Math.max(max,arr[i]);
        } {
            max = Math.max(max,arr[i]);
        } max = Math.max(max,arr[i]) max Math.max(max,arr[i]) Math.max Math max arr[i] arr i int maxIndex = 0; maxIndex 0 for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        } {
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        } if(max == arr[i]){
                maxIndex = i;
                break;
            } max == arr[i] max arr[i] arr i {
                maxIndex = i;
                break;
            } maxIndex = i maxIndex i break; if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        } maxIndex == n maxIndex n {
            found = true;
            System.out.println("Yes");
        } found = true found true System.out.println("Yes") System.out.println System.out System System.out "Yes" for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        } int i = maxIndex + 1; int i = maxIndex + 1; i maxIndex + 1 maxIndex 1 i++ i++ i {
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        } {
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        } if(i == n) {break;} i == n i n {break;} break; if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            } max - arr[i] >= 2 max - arr[i] max arr[i] arr i 2 {
                System.out.println("No"); found = true;break;
                
            } System.out.println("No") System.out.println System.out System System.out "No" found = true found true break; if(found == false){
            System.out.println("Yes");
        } found == false found false {
            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();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
} public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        boolean found = false;
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        int max = 0;
        if(n == 1){ System.out.println("Yes");}
        if(n != 1){for(int i = 0;i < n - 1;i++){
            max = Math.max(max,arr[i]);
        }
        int maxIndex = 0;
        for(int i = 0;i < n - 1;i++){
            if(max == arr[i]){
                maxIndex = i;
                break;
            }
        }
        
        if(maxIndex == n){
            found = true;
            System.out.println("Yes");
        }
        for(int i = maxIndex + 1;;i++){
            if(i == n) {break;}
            if(max - arr[i] >= 2 ){
                System.out.println("No"); found = true;break;
                
            }
            
        }
        if(found == false){
            System.out.println("Yes");
        }
    }
    }
}