import sys

input = sys.stdin.readline



N = int(eval(input()))

H = [int(item) for item in input().split()]



cand = []

cand += [H[0], H[0] - 1]

for i in range(1, N):

    new_cand = []

    for c in cand:

        if c <= H[i] - 1:

            new_cand += [H[i], H[i] - 1]

        elif c == H[i]:

            new_cand += [H[i]]

    cand = list(set(new_cand))

    if len(cand) == 0:

        print("No")

        break

else:

    print("Yes")

import sys

input = sys.stdin.readline



N = int(eval(input()))

H = [int(item) for item in input().split()]



c_height = -1

for h in H:

    if h - 1 >= c_height:

        c_height = h - 1

    elif h == c_height:

        pass

    else:

        print("No")

        break

else:

    print("Yes")

import sys

input = sys.stdin.readline
N = int(eval(input()))
H = [int(item) for item in input().split()]
cand = []
cand += [H[0], H[0] - 1]
for i in range(1, N):
    new_cand = []
    for c in cand:
        if c <= H[i] - 1:
            new_cand += [H[i], H[i] - 1]
        elif c == H[i]:
            new_cand += [H[i]]
    cand = list(set(new_cand))
    if len(cand) == 0:
        print("No")
        break
else:
    print("Yes")

import sys

input = sys.stdin.readline
N = int(eval(input()))
H = [int(item) for item in input().split()]
c_height = -1
for h in H:
    if h - 1 >= c_height:
        c_height = h - 1
    elif h == c_height:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

-cand = [] -cand += [H[0], H[0] - 1] -for i in range(1, N): -    new_cand = [] -    for c in cand: -        if c <= H[i] - 1: -            new_cand += [H[i], H[i] - 1] -        elif c == H[i]: -            new_cand += [H[i]] -    cand = list(set(new_cand)) -    if len(cand) == 0: +c_height = -1 +for h in H: +    if h - 1 >= c_height: +        c_height = h - 1 +    elif h == c_height: +        pass +    else: