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.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.StringTokenizer;

/**
 * @author ayratgdl
 * @date 01.04.18
 */
public class CF20180401C {
    int n;
    int[] a;
    public static void main(String[] args) {
        new CF20180401C().solve(System.in, System.out);
    }

    public void solve(InputStream input, OutputStream output) {
        In in = new In(input);
        Out out = new Out(output);

        n = in.int1();
        a = in.ints(n);
        int size = n;
        while (size > 1) {
            int max = 0;
            int maxI = -1;
            for (int i = 0; i < n; i++) {
                if (a[i] == 0) {
                    continue;
                }
                if (!checkCorrect(i)) {
                    out.write("NO").ln();
                    return;
                }
                if (maxI == -1 || a[i] > max) {
                    maxI = i;
                    max = a[i];
                }
            }
            a[maxI] = 0;
            size--;
        }
        out.write("YES").ln();
    }

    private boolean checkCorrect(int i) {
        for (int j = i+1; j < a.length; j++) {
            if (a[j] != 0) {
                int r = a[i] - a[j];
                return r <= 1 && r >= -1;
            }
        }
        return true;
    }

    public class In {
        private BufferedReader reader;
        StringTokenizer tokener;

        public In(BufferedReader reader) {
            this.reader = reader;
        }

        public In(Reader reader) {
            this.reader = new BufferedReader(reader);
        }

        public In(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int int1() {
            return Integer.parseInt(word());
        }

        public String word() {
            try {
                if (tokener == null || !tokener.hasMoreTokens())
                    tokener = new StringTokenizer(reader.readLine());
                return tokener.nextToken();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public long long1() {
            return Long.parseLong(word());
        }

        public String[] words(int n) {
            String[] result = new String[n];
            for (int i = 0; i < n; i++)
                result[i] = word();
            return result;
        }

        public int[] ints(int n) {
            int[] result = new int[n];
            for (int i = 0; i < n; i++)
                result[i] = Integer.parseInt(word());
            return result;
        }

        public long[] longs(int n) {
            long[] result = new long[n];
            for (int i = 0; i < n; i++)
                result[i] = Long.parseLong(word());
            return result;
        }
    }

    public class Out {
        private BufferedWriter writer;
        private boolean isEmptyLine = true;

        public Out(BufferedWriter writer) {
            this.writer = writer;
        }

        public Out(Writer writer) {
            this.writer = new BufferedWriter(writer);
        }

        public Out(OutputStream out) {
            this.writer = new BufferedWriter(new OutputStreamWriter(out));
        }

        private Out write(String str) {
            try {
                if (!isEmptyLine)
                    writer.write(" ");
                else
                    isEmptyLine = false;
                writer.write(str);
                return this;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public Out ln() {
            try {
                writer.newLine();
                writer.flush();
                isEmptyLine = true;
                return this;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public Out write(Object obj) {
            return write(obj.toString());
        }

        public Out write(int num) {
            return write(Integer.toString(num));
        }

        public Out write(long num) {
            return write(Long.toString(num));
        }

        public Out write(Object[] objs) {
            for (Object obj : objs)
                write(obj);
            return this;
        }

        public <T> Out write(Iterable<T> iter) {
            for (T obj : iter)
                write(obj);
            return this;
        }

        public Out write(int[] nums) {
            for (int num : nums)
                write(num);
            return this;
        }

        public Out write(long[] nums) {
            for (long num : nums)
                write(num);
            return this;
        }
    }
}
