import sys

input = sys.stdin.readline



n=int(eval(input()))

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

l=h

s=[]

t=max(h)



for i in range(n-1):

        if l[i]-1==l[i+1]:

                l[i]=l[i]-1

                s.append(l[i])

        elif l[i]==l[i+1] and l[i]==t:

                l[i]=l[i]-1

                s.append(l[i])

        elif l[i]-1>l[i+1]:

                break

        elif l[i]-1<l[i+1]:

                s.append(l[i])

                continue



s.append(h[n-1])

s.sort()

if len(s)==n:

        if l==s:

                print('Yes')

        else:

                print('No')



else:

        print('No')





n=int(eval(input()))

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



if n==1:

    print('Yes')



else:

    c=0

    for i in range(n):

        if c<h[i]:

            h[i]-=1

            c=h[i]

        elif c==h[i]:

            c=h[i]

        else:

            print('No')

            break

    else:

        print('Yes')



import sys

input = sys.stdin.readline
n = int(eval(input()))
h = list(map(int, input().split()))
l = h
s = []
t = max(h)
for i in range(n - 1):
    if l[i] - 1 == l[i + 1]:
        l[i] = l[i] - 1
        s.append(l[i])
    elif l[i] == l[i + 1] and l[i] == t:
        l[i] = l[i] - 1
        s.append(l[i])
    elif l[i] - 1 > l[i + 1]:
        break
    elif l[i] - 1 < l[i + 1]:
        s.append(l[i])
        continue
s.append(h[n - 1])
s.sort()
if len(s) == n:
    if l == s:
        print("Yes")
    else:
        print("No")
else:
    print("No")

n = int(eval(input()))
h = list(map(int, input().split()))
if n == 1:
    print("Yes")
else:
    c = 0
    for i in range(n):
        if c < h[i]:
            h[i] -= 1
            c = h[i]
        elif c == h[i]:
            c = h[i]
        else:
            print("No")
            break
    else:
        print("Yes")

-import sys - -input = sys.stdin.readline -l = h -s = [] -t = max(h) -for i in range(n - 1): -    if l[i] - 1 == l[i + 1]: -        l[i] = l[i] - 1 -        s.append(l[i]) -    elif l[i] == l[i + 1] and l[i] == t: -        l[i] = l[i] - 1 -        s.append(l[i]) -    elif l[i] - 1 > l[i + 1]: -        break -    elif l[i] - 1 < l[i + 1]: -        s.append(l[i]) -        continue -s.append(h[n - 1]) -s.sort() -if len(s) == n: -    if l == s: +if n == 1: +    print("Yes") +else: +    c = 0 +    for i in range(n): +        if c < h[i]: +            h[i] -= 1 +            c = h[i] +        elif c == h[i]: +            c = h[i] +        else: +            print("No") +            break +    else: -    else: -        print("No") -else: -    print("No")