CodeEff/ECCO huggingface dataset:
# Original solution
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(eval(input()))

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

    ans = 'Yes'

    for x in reversed(list(range(1, len(nums)))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

        elif nums[x-1] - nums[x] == 1:
            nums[x-1] -= 1

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()



# Optimized solution
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


# def main():
#     n = int(input())
#
#     nums = list(map(int, input().split()))
#
#     ans = 'Yes'
#
#     for x in reversed(range(1, len(nums))):
#         if nums[x-1] - nums[x] >= 2:
#             ans = 'No'
#
#         elif nums[x-1] - nums[x] == 1:
#             nums[x-1] -= 1
#
#         else:
#             continue
#
#     print(ans)
#
#
# if __name__ == '__main__':
#     main()


def main():
    n = int(eval(input()))

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

    for x in reversed(list(range(1, len(nums)))):
        if nums[x-1] > nums[x]:
            nums[x-1] -= 1

        if nums[x-1] > nums[x]:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
h=[int(i) for i in input().split()]
f=1
h[0]-=1
for i in range(1,n):
    if h[i]-h[i-1]>=1:h[i]+=-1
    elif h[i]-h[i-1]==0:h[i]+=0
    else:
        f=0
        print("No")
        break
if f==1:print("Yes")


# Optimized solution
# 実行時間超過

N=int(eval(input()))
n = list(map(int, input().split()))

for i in range(N-1):
    if n[i+1]-n[i]>=1:
        n[i+1]-=1
    elif n[i+1]-n[i]<=-1:    
        print("No")
        exit()
print("Yes")
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
t=l.pop(0)-1
for i in l:
  if i<t: print('No'); exit()
  if i>t: t=i-1
print('Yes')

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
t=0
for i in l:
  if i<t: print('No'); exit()
  if i>t: t=i-1
print('Yes')
# Original solution
n,*l=list(map(int,open(0).read().split()))
t=0
for i in l:
  if i<t: print('No'); break
  if i>t: i-=1
  t=i
else: print('Yes')

# Optimized solution
n,*l=list(map(int,open(0).read().split()))
t=0
for i in l:
  if i<t: print('No'); exit()
  if i>t: t=i-1
print('Yes')
# Original solution
N = int(eval(input()))

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

for i in range(N-1):
    for j in range(i+1,N):
        if H[j] - (H[i]-1) < 0:
            print('No')
            exit()
print('Yes')

# Optimized solution
N = int(eval(input()))

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

for i in range(N-1,0,-1):
    if 2 <= H[i-1] - H[i]:
        print('No')
        exit()
    else:
        if (H[i-1] - 1) == H[i]:
            H[i-1] -= 1
print('Yes')
# Original solution
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(eval(input()))
#g=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#a=[int(input()) for _ in range(k)]
h=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#m=[list(map(int,input().split()))for _ in range(n)]
#p=[list(input().split())for _ in range(h)]
#a=[input()for _ in range(n)]
for i in range(1,n):
    left=max(h[:i])-1
    if h[i]<left:
        print("No")
        exit()
print("Yes")


# Optimized solution
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(eval(input()))
#g=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#a=[int(input()) for _ in range(k)]
h=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#m=[list(map(int,input().split()))for _ in range(n)]
#p=[list(input().split())for _ in range(h)]
#a=[input()for _ in range(n)]
tmp=h[0]
for i in range(1,n):
    if tmp<h[i]:
        tmp=h[i]
        tmp-=1
    if h[i]<tmp:
        print("No")
        exit()
print("Yes")
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n-1):
    if h[i] <= h[i+1] + 1:
        if h[i-1] != h[i]:
            h[i] -= 1
    else:
        print('No')
        exit()
for i in range(n-1):
    if h[i] > h[i+1]:
        print('No')
        exit()
print('Yes')

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n-1):
    if h[i] == h[i+1] + 1:
        if h[i-1] != h[i]:
            h[i] -= 1
        else:
            print('No')
            exit()
    elif h[i] < h[i+1] + 1:
        if h[i-1] != h[i]:
            h[i] -= 1
    else:
        print('No')
        exit()
print('Yes')
# Original solution
import sys

N = int(eval(input()))
H = list(map(int, input().split()))
ans = ("Yes")

for i in range(N-1):
  for j in range(N-i-1):
    if H[i]-H[i+j+1] >= 2:
      ans = ("No")
      print(ans)
      sys.exit()
      
print(ans)

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
ans = ("Yes")

for i in range(N-1):
    if H[N-1-i] - H[N-2-i] == -1:
        H[N-2-i] -= 1
    elif H[N-1-i] - H[N-2-i] <= -2:
        ans = ("No")

print(ans)
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))

for i in range(len(h)-1):
  if h[i] > h[i+1]:
    h[i] = h[i] - 1
  elif h[i] == h[i+1]:
    if h[i] == min(h[i:])+1:
      h[i] = h[i] - 1
if h == sorted(h):
  print('Yes')
else:
  print('No')

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))

for i in reversed(list(range(1,n))):
  if h[i-1] - h[i] == 1:
    h[i-1] -= 1
  elif h[i-1] - h[i] > 1:
    print('No')
    exit()
print('Yes')
# Original solution
N = int(eval(input()))
b_list = list(map(int,input().split()))
d_list = [True for i in range(N)]
s = True
b_list.append(1000000000)
for _ in range(N):
  for i in range(len(b_list)-1):
    if (b_list[i] > b_list[i+1]):
      if (d_list[i]):
        b_list[i] -= 1
        d_list[i] = False
      else:
        s = False
        break
if (s):
  print('Yes')
else:
  print('No')

# Optimized solution
N = int(eval(input()))
b_list = list(map(int,input().split()))
s = True
if (b_list[0] > 1):
  b_list[0] -= 1
for i in range(1,len(b_list)):
  if (b_list[i-1] < b_list[i]):
    b_list[i] -= 1
for i in range(len(b_list)-1):
  if (b_list[i] > b_list[i+1]):
    s = False
if (s):
  print('Yes')
else:
  print('No')
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))

for i in range(1,n):
  if h[i] < h[i-1]:
    h[i] += 1
    
for i in range(1,n):
  if h[i] < h[i-1]:
    print("No")
    exit()

print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))[::-1]

for i in range(1,n):
  if h[i] - h[i-1] > 1:
    print("No")
    exit()
  elif h[i] - h[i-1] == 1:
    h[i] -= 1
print("Yes")
# Original solution
n = int(eval(input()))
H_l = list(map(int, input().split()))

flg_nd = True
for i in range(n-1):
    if H_l[i] >=3:
        H_min = min(H_l[i+1:])
        if H_l[i] - H_min >=2:
            flg_nd = False
            break;
    
if flg_nd:
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
H_l = list(map(int, input().split()))
tmp_max = 0
flg_nd = True
for i in range(n):
    if tmp_max - H_l[i] >=2:
        flg_nd = False
        break;
    if H_l[i] > tmp_max:
        tmp_max = H_l[i]

if flg_nd:
    print('Yes')
else:
    print('No')
# Original solution
N = int(eval(input()))
Hs = [int(x) for x in input().split()]

# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.

prev = 'init'
is_yes = True
for i in range(N):
    current = Hs[N-1-i]
    if prev == 'init':
        prev = current
        continue
    elif prev >= current:
        prev = current
    elif prev == current - 1:
        prev = current - 1
    else:
        is_yes = False

if is_yes:
    print('Yes')
else:
    print('No')


# Optimized solution
N = int(eval(input()))
Hs = [int(x) for x in input().split()]


# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.

def is_yes(Hs):
    max = 0
    for H in Hs:
        # print("H: " + H)
        if H > max:
            max = H
        # print("max: " + max)
        if max - H >= 2:
            return False
    return True

if is_yes(Hs):
    print('Yes')
else:
    print('No')
# Original solution
import sys
N=int(eval(input()))

H=[int(x) for x in input().rstrip().split()]
flag=0
mi=-1
for i in range(N-1):

  if H[i]<=H[i+1] and mi<=H[i]:
    mi=max(mi,H[i]-1)
    continue
  elif H[i+1]<H[i]:
    H[i]=H[i]-1
    mi=max(mi,H[i])
    if H[i+1]<H[i] or H[i]<mi:
      flag=1
      print("No")
      sys.exit()

if flag==0:
  print("Yes")



# Optimized solution
import sys
N=int(eval(input()))

H=[int(x) for x in input().rstrip().split()]
flag=0
mi=-1
for i in range(N-1):

  if H[i]<=H[i+1] and mi<=H[i]:
    mi=max(mi,H[i]-1)
    continue
  elif H[i+1]<H[i]:
    H[i]=H[i]-1
    mi=max(mi,H[i])
  if H[i+1]<H[i] or H[i]<mi:
    flag=1
    print("No")
    sys.exit()

if flag==0:
  print("Yes")
# Original solution
N = int(eval(input()))
H = [int(x) for x in input().split()]

ans = "Yes"
for i in range(1, N):
  if H[-(i + 1)] <= H[-i]:
    continue
  elif H[-(i + 1)] - 1 <= H[-i]:
    H[-(i + 1)] -= 1
  else:
    ans = "No"
    break
print(ans)

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))[::-1]
for i in range(1, n):
  if h[i-1] >= h[i]: continue
  if h[i-1] == h[i]-1:h[i] -= 1
  else:
    print("No")
    exit()
print("Yes")
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))[::-1]
for i in range(1, n):
  if h[i-1] >= h[i]: continue
  if h[i-1] == h[i]-1:h[i] -= 1
  else:
    print("No")
    exit()
print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))[::-1]
ans = "Yes"
for i in range(n-1):
    if h[i] >= h[i+1]: continue
    if h[i] >= h[i+1]-1:
        h[i+1] -= 1
    else:
        ans = "No"
        break
print(ans)
# Original solution
n, *a = list(map(int, open(0).read().split()))

for i in range(n): a[i] -= a[0]

mx = cant = 0
for i in range(n):
    mx = max(mx, a[i])
    if a[i]<mx-1: cant = True
print(("YNeos"[cant::2]))

# Optimized solution
n, *k = list(map(int, open(0).read().split()))
mx = cant = 0
for i in k:
        mx = max(mx, i)
        if mx-i>1: cant = True
print(("YNeos"[cant::2]))
# Original solution
# 2019-11-16 10:55:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *h = [int(x) for x in sys.stdin.read().split()]

    
    ans = 'Yes'
    maximum = h[0]
    for i in range(1, n):
        if maximum - h[i] >= 2:
            ans = 'No'
            break
        maximum = max(maximum, h[i])

    print(ans)
    



if __name__ == "__main__":
    main()


# Optimized solution
import sys

n, *H = list(map(int, sys.stdin.read().split()))

def main():
    cur = 0
    for h in H:
        if h > cur:
            cur = h - 1
        elif h < cur:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
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 = new_cand
    if len(cand) == 0:
        print("No")
        break
else:
    print("Yes")


# Optimized solution
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")
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))
H.append(0)
h1=0
h2=0
a=0
for i in range(N-1):
    h1=H[i+1]-H[i]
    if h1<-1:
        a=1
        break
    elif h1==-1:
        for j in range(1,N-i):
            h2=H[i]-H[i+j]
            if h2>=2:
                a=1
                break
    if a==1:
        break
if a==0:
    print('Yes')
else:
    print('No')

# Optimized solution
N=int(eval(input()))
H=list(map(int,input().split()))
a=0
for i in range(N-1)[::-1]:
    if H[i]>H[i+1]:
        H[i]-=1
for i in range(N-1):
    if H[i]>H[i+1]:
        a=1
        break
if a==0:
    print("Yes")
else:
    print("No")
# Original solution
N =int(eval(input()))
H = [int(x) for x in input().split()]
memo = 0
for i in range(N):
    if i==N-1:
        break
    elif H[i]-min(H[i+1:])>=2:
        memo+=1
if memo>=1:
    print('No')
else:
    print('Yes')  

# Optimized solution
N =int(eval(input()))
H = [int(x) for x in input().split()]
h=0
l=0
memo = 0
for i in range(N):
    if H[i]>=h:
        h=H[i]
    elif H[i]<h and H[i]>=l:
        l=H[i]
    else:
        memo+=1
for i in range(N):
    if i==N-1:
        break
    elif H[i]-H[i+1]>=2:
        memo+=1

if memo>=1:
    print('No')
else:
    print('Yes')
# Original solution
import sys

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

if n == 1:
    print('Yes')
    sys.exit()

cnt = 0
for i in range(n-1):
    if h[i] - h[i+1] == 1:
        cnt += 1
        if cnt == 2:
            print('No')
            sys.exit()
    elif h[i] - h[i+1] > 1:
        print('No')
        sys.exit()
    elif h[i] - h[i+1] < 0:
        cnt = 0

print('Yes')

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))

h[0] -= 1
for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] -= 1
    elif h[i] < h[i-1]:
        print('No')
        exit()
print('Yes')
# Original solution
n = int(eval(input()))
h_list = list(map(int, input().split()))

for i in range(n - 1, 0, -1):
    if max(h_list[:i]) - h_list[i] >= 2:
        print('No')
        break
else:
    print('Yes')

# Optimized solution
n = int(eval(input()))
h_list = list(map(int, input().split()))

min_v = h_list[-1]
for i in range(n - 1, 0, -1):
    if h_list[i] < min_v:
        min_v = h_list[i]
    if h_list[i - 1] - min_v >= 2:
        print('No')
        break
else:
    print('Yes')
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))
submax = 0

for i in range(n-1):
  for j in range(i+1,n):
    if h[i] - h[j] >= 2:
      submax = 1
      break
  if submax == 1:
    break

if submax == 1:
  print("No")
else:
  print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int,input().split()))
d = [1]+[0]*(n-1)

for i in range(n-1):
  if h[i] >= 2+ h[i+1]:
    print('No')
    exit()
  if d[i] == 1 and h[i] <= h[i+1]:
    d[i+1] = 1
  elif d[i] == 0:
    if h[i] +1 <=h[i+1]:
      d[i+1] = 1
    elif h[i] -1 == h[i+1]:
      print('No')
      exit()
      
print('Yes')
# Original solution
N = int(eval(input()))
l = list(map(int, input().split()))
d = 0
for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-1):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] == 1:
        d = 1

if d == 0:
  print("Yes")
else:
  print("No")

# Optimized solution
N = int(eval(input()))
l = list(map(int, input().split()))
d = 0

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")
# Original solution

def solve():
    ans = "Yes"
    for i in range(1,N):
        tmp = min(H[i:])
        if H[i-1] - tmp > 1:
            ans = "No" 
            break
    print(ans)

if __name__ == "__main__":
    N = int(eval(input()))
    H = list(map(int, input().split()))  
    solve()


# Optimized solution

def solve():
    ans = "Yes"
    for i in range(1,N-1):
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                ans = "No"
                break
            if H[i-1] > H[i]:
                ans = "No"
                break
        elif H[i-1] <= H[i]-1:
            H[i] -= 1
    print(ans)

if __name__ == "__main__":
    N = int(eval(input()))
    H = list(map(int, input().split()))  
    solve()
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

flag = True
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
if flag:
    print('Yes')


# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))

for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
else:
    print('Yes')
# Original solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(eval(input()))
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
HH = inpl()
HH[0] -= 1
for i in range(N-1):
    #print(HH)
    if HH[i+1]-HH[i] > 0:
        HH[i+1] -= 1
    elif HH[i+1]-HH[i] == 0:
        continue
    else:
        print('No')
        exit()

print('Yes')


# Optimized solution
N = int(eval(input()))
hh = list(map(int, input().split()))

for i in range(1, N):
    if hh[i - 1] == hh[i]:
        continue
    else:
        hh[i] -= 1
    if hh[i - 1] > hh[i]:
        print("No")
        exit()

print("Yes")
# Original solution
N,*H=list(map(int,open(0).read().split()))
H[0]-=1
def main():
    ihmax=0
    hmax=H[0]
    for i in range(1,N):
        if H[i-1]<H[i]:
            ihmax=i-1
            H[i]-=1
            hmax=max(H[i],hmax)
        elif H[i-1]==H[i]:
            continue
        else:
            return 'No'
    return 'Yes'
print((main()))

# Optimized solution
N,*H=list(map(int,open(0).read().split()))
H[0]-=1
def main():
    for i in range(1,N):
        if H[i-1]<H[i]:
            H[i]-=1
        elif H[i-1]==H[i]:
            continue
        else:
            return 'No'
    return 'Yes'
print((main()))
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
x=0
flg=0
while(x<n):
    j=x+1
    while(j<n):
        if(l[j]<l[x]-1):
            flg=1
            break
        j+=1
    x+=1
if(flg==0):
    print("Yes")
else:
    print("No")

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
x=[]
i=0
flag=0
for i in range(n-1,0,-1):
    if(l[i]<l[i-1]):
        if(l[i-1]-1<=l[i]):
            l[i-1]-=1
        else:
            flag=1
if(flag==0):
    print("Yes")
else:
    print("No")
# Original solution
import sys

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

def main():
  for i in reversed(list(range(n-1))):
    if h[i] - h[i+1] > 1:
      return False
      exit()
    elif h[i] - h[i+1] == 1:
      h[i] -= 1
    else:
      continue
  return True

if main() == True:
  print('Yes')
  sys.exit()

h[n-1] -= 1

if main() == True:
  print('Yes')

else:
  print('No')

# Optimized solution


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

def main():
  for i in reversed(list(range(n-1))):
    if h[i] - h[i+1] > 1:
      return False
      exit()
    elif h[i] - h[i+1] == 1:
      h[i] -= 1
    else:
      continue
  return True

if main() == True:
  print('Yes')

else:
  print('No')
# Original solution
n = int(eval(input()))
h = [int(i) for i in input().split()]
ans = 'Yes'
for i in range(n - 1, 0, -1):
    d = h[i - 1] - h[i]
    if d >= 2:
        ans = 'No'
        break
    elif d == 1:
        h[i - 1] -= 1
print(ans)

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 'Yes'
for i in range(n - 1, 0, -1):
    d = h[i - 1] - h[i]
    if d >= 2:
        ans = 'No'
        break
    elif d == 1:
        h[i - 1] -= 1
print(ans)
# Original solution
import sys
n = int(eval(input()))
h = [int(e) for e in input().split()]
for i in range(n - 2, 0, -1):
  if h[i] > h[i + 1]:
    h[i] -= 1
  if h[i] > h[i + 1]:
    print('No')
    sys.exit()
print('Yes')


# Optimized solution
from sys import exit

N = int(eval(input()))
H = list(map(int, input().split()))

for i in range(N - 2, 0, -1):
    if H[i] <= H[i + 1]:
        continue
    H[i] -= 1
    if H[i] > H[i + 1]:
        print('No')
        exit()
print('Yes')
# Original solution
import sys
import random
N = int(eval(input()))
H = [int(x) for x in input().split()]

if N==1:
    print("Yes")
    sys.exit()

K_left=H[1]-H[0]
if K_left<-1:
    print("No")
    sys.exit()
elif K_left == -1 :
    L_left='-'
elif K_left == 0 :
    L_left='0'
else:
    L_left='+'

for i in range(1,N-1):
    K_right=H[i+1]-H[i]    
    if K_right < -1:
        print("No")
        sys.exit()
    elif K_right == -1 :
        L_right='-'
    elif K_right == 0 :
        L_right='0'
    else:
        L_right='+'

    if L_left =='-' and L_right=='-':
        print("No")
        sys.exit()
    if L_left =='0' and L_right=='-':
        if max(H[0:i]) <= H[i]:
            L_left=L_right
            K_left=K_right
        else:
            print("No")
            sys.exit()
    else:
        L_left=L_right
        K_left=K_right
print("Yes")

# Optimized solution
import sys
import random
N = int(eval(input()))
H = [int(x) for x in input().split()]

if N==1:
    print("Yes")
    sys.exit()

K_left=H[1]-H[0]
if K_left<-1:
    print("No")
    sys.exit()
elif K_left == -1 :
    L_left='-'
elif K_left == 0 :
    L_left='0'
else:
    L_left='+'
maxH=max(H[1],H[0])
for i in range(1,N-1):
    K_right = H[i+1]-H[i]    
    if K_right < -1:
        print("No")
        sys.exit()
    elif K_right == -1 :
        L_right='-'
    elif K_right == 0 :
        L_right='0'
    else:
        L_right='+'

    if L_left =='-' and L_right=='-':
        print("No")
        sys.exit()
    if L_left =='0' and L_right=='-':
        if maxH <= H[i]:
            L_left=L_right
            K_left=K_right
        else:
            print("No")
            sys.exit()
    else:
        L_left=L_right
        K_left=K_right
        maxH=max(H[i+1],maxH)
print("Yes")
# Original solution
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
for i in range(1, len(h_list)-1):
    # print(h_list[i])
    min_right_h = min(h_list[i+1:])
    if h_list[i] <= min_right_h:
        # 右側最小値以下の場合
        if h_list[i] >= h_list[i-1]:
            # 左側の値以上の場合
            continue
    else:
        # 右側最小値以上の場合
        h_list[i] -= 1
        if min_right_h >= h_list[i] >= h_list[i - 1]:
            continue
        else:
            result = 'No'
            flag = False
    if not flag:
        break

print(result)


# Optimized solution
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
min_h_list = min(h_list[1:-1])
for i in range(1, len(h_list)-1):
    if h_list[i] - 1 >= h_list[i-1]:
        h_list[i] -= 1

for i in range(1, len(h_list)-1):
    if not (h_list[i-1] <= h_list[i] <= h_list[i+1]):
        result = 'No'

print(result)