def resolve():

    n = int(eval(input()))

    h = list(map(int, input().split()))

    flag = 0

    for i in range(n-1):

        if h[i] == h[i+1]:

            continue

        else:

            h[i+1] -= 1

            if h[i] <= h[i+1]:

                continue

            else:

                print("No")

                exit()

    print("Yes")

resolve()
def resolve():

    n = int(eval(input()))

    h = list(map(int, input().split()))

    OK = True

    for i in range(1, len(h)):

        if h[i] == h[i-1]:

            continue

        elif h[i] > h[i-1]:

            h[i] -= 1

        else:

            OK = False

            break

    if OK:

        print("Yes")

    else:

        print("No")

resolve()
def resolve():
    n = int(eval(input()))
    h = list(map(int, input().split()))
    flag = 0
    for i in range(n - 1):
        if h[i] == h[i + 1]:
            continue
        else:
            h[i + 1] -= 1
            if h[i] <= h[i + 1]:
                continue
            else:
                print("No")
                exit()
    print("Yes")


resolve()

def resolve():
    n = int(eval(input()))
    h = list(map(int, input().split()))
    OK = True
    for i in range(1, len(h)):
        if h[i] == h[i - 1]:
            continue
        elif h[i] > h[i - 1]:
            h[i] -= 1
        else:
            OK = False
            break
    if OK:
        print("Yes")
    else:
        print("No")


resolve()

-    flag = 0 -    for i in range(n - 1): -        if h[i] == h[i + 1]: +    OK = True +    for i in range(1, len(h)): +        if h[i] == h[i - 1]: +        elif h[i] > h[i - 1]: +            h[i] -= 1 -            h[i + 1] -= 1 -            if h[i] <= h[i + 1]: -                continue -            else: -                print("No") -                exit() -    print("Yes") +            OK = False +            break +    if OK: +        print("Yes") +    else: +        print("No")