import math

import os

import random

import re

import sys



def check_non_decreasing_squares(n: int, a: list):

    for i in range(1, n):

        if a[i] != a[i - 1]:

            if a[i] - 1 < a[i - 1]:

                print("No")

                sys.exit(0)

            a[i] -= 1

    print("Yes")



if __name__ == '__main__':

    n = int(eval(input()))

    a = list(map(int, input().rstrip().split()))

    check_non_decreasing_squares(n, a)
import math

import os

import random

import re

import sys



def check_non_decreasing_squares(n: int, a: list):

    p = a[0]

    for i in range(1, n):

        if a[i] > p:

            p = a[i]

        if p - a[i] == 1 or p - a[i] == 0:

            continue

        print("No")

        exit(0)

    print("Yes")



if __name__ == '__main__':

    n = int(eval(input()))

    a = list(map(int, input().rstrip().split()))

    check_non_decreasing_squares(n, a)
import math
import os
import random
import re
import sys


def check_non_decreasing_squares(n: int, a: list):
    for i in range(1, n):
        if a[i] != a[i - 1]:
            if a[i] - 1 < a[i - 1]:
                print("No")
                sys.exit(0)
            a[i] -= 1
    print("Yes")


if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int, input().rstrip().split()))
    check_non_decreasing_squares(n, a)

import math
import os
import random
import re
import sys


def check_non_decreasing_squares(n: int, a: list):
    p = a[0]
    for i in range(1, n):
        if a[i] > p:
            p = a[i]
        if p - a[i] == 1 or p - a[i] == 0:
            continue
        print("No")
        exit(0)
    print("Yes")


if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int, input().rstrip().split()))
    check_non_decreasing_squares(n, a)

+    p = a[0] -        if a[i] != a[i - 1]: -            if a[i] - 1 < a[i - 1]: -                print("No") -                sys.exit(0) -            a[i] -= 1 +        if a[i] > p: +            p = a[i] +        if p - a[i] == 1 or p - a[i] == 0: +            continue +        print("No") +        exit(0)