4
90 91 90 91
 4
54 54 54 55
 10
55 39 93 42 97 40 36 38 11 97
 3
90 39 98
 5
21 57 40 94 17
 8
46 4 30 85 52 6 84 13
 6
47 100 96 2 96 43
 4
61 28 3 81
 5
14 91 91 91 84
 3
22 23 24
 1
13
 9
13 80 13 38 98 85 11 73 74
 10
95 51 52 8 44 39 77 17 96 88
 3
40 40 40
 4
16 17 17 18
 3
68 67 67
 4
83 100 81 75
 9
71 71 70 70 71 70 69 70 71
 10
9 9 9 10 10 9 8 8 9 9
 6
87 86 86 86 85 86
 5
64 63 63 62 61
 3
76 9 12
 4
61 60 60 60
 7
23 37 39 8 72 31 85
 10
67 67 67 67 67 67 67 67 67 67
 4
92 18 29 93
 4
14 15 15 16
 10
79 84 22 38 23 22 33 42 13 96
 7
20 21 95 73 49 98 53
 10
28 61 23 73 61 33 45 55 18 43
 9
15 14 14 13 13 12 13 13 14
 5
46 46 47 46 45
 7
35 91 87 78 17 71 63
 3
69 26 73
 10
16 17 16 15 14 15 16 17 16 15
 9
95 7 97 61 90 7 30 65 39
 10
2 83 18 65 58 95 37 51 86 47
 6
59 59 60 60 59 58

YES YES NO NO NO NO NO NO NO YES YES NO NO YES YES YES NO YES YES YES YES NO YES NO YES NO YES NO NO NO YES YES NO NO YES NO NO YES
/*
ЗАПУСКАЕМ ВЫСОКОГО
░ГУСЯ░▄▀▀▀▄░РАБОТЯГИ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */

import java.io.*;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = readInt();
        int[] a = readIntArray(n);
        int[] ind = new int[n];
        ArrayList<Integer> list = new ArrayList<>();
        ArrayList<Integer> sorted = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(a[i]);
        }
        for (int inr = 0; inr < n; inr++) {
            for (int i = 1; i < list.size(); i++) {
                if (Math.abs(list.get(i) - list.get(i - 1)) > 1) {
                    out.print("NO");
                    return;
                }
            }
            int max = -1;
            for (int i : list) {
                max = maxInt(max, i);
            }
            for (int i = 0; i < n; i++) {
                if (list.get(i) == max) {
                    sorted.add(list.get(i));
                    list.remove(i);
                    break;
                }
            }
        }
        Arrays.parallelSort(a);
        Collections.reverse(sorted);
        for (int i = 0; i < n; i++) {
            if (a[i] != sorted.get(i)) {
                out.print("NO");
                return;
            }
        }
        out.print("YES");
    }

    boolean sorted(int[] a, int n) {
        int[] b = a.clone();
        Arrays.sort(b);
        boolean ans = true;
        for (int i = 0; i < n; i++) ans &= a[i] == b[i];
        return ans;
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;

    Main() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        tok = new StringTokenizer("");
    }

    void run() throws IOException {
        solve();
        out.close();
    }


    class Fenwik {
        private long[] t;
        private int length;

        Fenwik(int[] a) {
            this.length = a.length + 100;
            this.t = new long[length];
            for (int i = 0; i < a.length; ++i) this.inc(i, a[i]);
        }

        void inc(int i, int delta) {
            for (; i < this.length; i = i | (i + 1)) t[i] += delta;
        }

        long getSum(int r) {
            long sum = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1) sum += this.t[r];
            return sum;
        }

    }

    String delimiter = " ";

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) return null;
            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken(delimiter);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int b) {
        int a[] = new int[b];
        for (int i = 0; i < b; i++)
            try {
                a[i] = readInt();
            } catch (IOException e) {
                e.printStackTrace();
            }
        return a;
    }

    int[] readSortedIntArray(int size) throws IOException {
        Integer[] array = new Integer[size];
        for (int index = 0; index < size; ++index) array[index] = readInt();
        Arrays.sort(array);
        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) sortedArray[index] = array[index];
        return sortedArray;
    }

    int[] sortedIntArray(int size, int[] array) throws IOException {
        for (int index = 0; index < size; ++index) array[index] = readInt();
        Arrays.sort(array);
        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) sortedArray[index] = array[index];
        return sortedArray;
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) min = Math.min(min, value);
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) max = Math.max(max, value);
        return max;
    }

    long minLong(long... values) {
        long min = Long.MAX_VALUE;
        for (long value : values) min = Math.min(min, value);
        return min;
    }

    long maxLong(long... values) {
        long max = Long.MIN_VALUE;
        for (long value : values) max = Math.max(max, value);
        return max;
    }

    boolean checkIndex(int index, int size) {
        return (0 <= index && index < size);
    }

    int abs(int a) {
        if (a < 0) return -a;
        return a;
    }
}