peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())
#n,m=map(int,input().split())
#t=int(input())
hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

flag="Yes"

for i in range(n-2,-1,-1):
    righth=hl[i+1]
    cur=hl[i]
    if cur<=righth:
        pass
    elif cur==righth+1:
        hl[i]=cur-1
    else:
        flag="No"
        break

print(flag)
N = int(input())
H = list(map(int, input().split()))
import sys
prev = -999
for i in range(N):
    if prev <= H[i] - 1:
        prev = H[i] - 1
    elif prev == H[i]:
        prev = H[i]
    else:
        print('No')
        sys.exit(0)
print('Yes')
n = int(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')
n = int(input())
hoge_list = list(map(int,input().split()))
h_list = hoge_list[::-1]
mae = h_list[0]
s = 0
for h in h_list:
  if h <= mae:
    mae = h
  elif h-1 == mae:
    mae = h-1
  else:
    print('No')
    s += 1
    break
if s == 0:
  print('Yes')
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

flag = True
for i in reversed(range(1,n)):
    if h[i-1] <= h[i]: continue
    if h[i-1]-1 <= h[i]: h[i-1] -= 1
    elif h[i] < h[i-1]-1:
        flag = False
        break

if flag: print("Yes")
else: print("No")
n = int(input())
h = list(map(int, 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')
      break
else:
   print('Yes')
N = int(input())
H = list(map(int, input().split()))
H = H[::-1]
flag = True
for i in range(N-1):
    if H[i+1] > H[i]:
        H[i+1] -= 1
    if H[i+1] > H[i]:
        flag = False
        break
    
if flag:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int,input().split()))
flag = True
num = 0
for i in range(N-1):
  if H[i] - 1 == H[i+1] and H[i+1] >= num: 
    num = H[i+1]
  elif H[i] - 1 == H[i+1] and H[i+1] < num:
    flag = False
    break
  elif H[i] -1 > H[i+1]:
    flag = False
    break
if flag == True:
  print("Yes")
else:
  print("No")
n = int(input())
H = list(map(int, input().split()))
 
H[0] -= 1
for i in range(1, n):
    if H[i-1] < H[i]:
        H[i] -= 1
print('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No')
N = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(N-2, 0, -1):
    defe = H[i] - H[i+1]
    if defe > 1:
        flag = False
        break
    elif defe == 1:
        H[i] -= 1
print('Yes' if flag else 'No')
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    h = list(map(int, input().split()))
    hi = 0
    lo = 10**9
    for i in range(0, n):
        hi = max(h[i], hi)
        if h[i] == hi:
            lo = hi
        lo = min(h[i], lo)
        if hi-lo >= 2:
            print("No")
            exit()

    print("Yes")


if __name__ == '__main__':
    main()
def main():
    N = int(input())
    H = list(map(int, input().split()))
    Max = 0
    for i in range(N):
        if H[i] > Max:
            H[i] -= 1
            Max = H[i]
        elif H[i] == Max:
            pass
        else:
            print('No')
            return
    print('Yes')
main()
N = int(input())
H = list(map(int, input().split()))

for i in range(len(H)-1, 0, -1):
    if H[i-1] == H[i] + 1:
        H[i-1] -= 1
    elif H[i-1] > H[i]:
        print('No')
        break
else:
    print('Yes')
import sys
N = int(input())
HN = list(map(int,input().split()))
HN.reverse()
if N == 1:
  print("Yes")
  sys.exit()
  
for n in range(N-1):
  left = HN[n]
  right = HN[n+1]
  if left-right >= 0:
    continue
  elif left-right == -1:
    HN[n+1] -= 1
  else:
    print("No")
    sys.exit()
print("Yes")
def check():
    N = int(input())
    H = list(map(int, input().split()))
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]+1:
            return 'No'
        if H[i]>H[i+1]:
            H[i] -= 1
    return 'Yes'
print(check())
n=int(input())
h=list(map(int,input().split()))
x=h[0]-1
ans='Yes'
for i in h[1:]:
  x=max(x,i)
  if x-i>=2:
    ans='No'
print(ans)
n = int(input())
A = list(map(int, input().split( )))
cnt = 0
for i in range(n-1):
  if A[i] < A[i+1]:
    A[i+1] -= 1
  cnt += max(A[i] - A[i+1],0)
  if cnt >= 1:
    print('No')
    exit()
print('Yes')
N = int(input())
H = list(map(int,input().split()))

for i in range(1, N):
    if H[-i] < H[-(i+1)]:
        H[-(i+1)] -= 1
    if H[-i] < H[-(i+1)]:
        print("No")
        exit()
print("Yes")
def main():
    n = input()
    h = list(map(int, input().split()))[::-1]
    low = h[0]
    for i in h:
        if low > i:
            low = i
        elif i - low > 1:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()
n = int(input())
h = list(map(int, input().split()))

for i in range(1,n):
    if h[i-1]-h[i]>0:
        print('No')
        exit()
    elif h[i-1]-h[i] <= -1:
        h[i] -= 1
print('Yes')
def q3():
    N = int(input())
    H = [int(i) for i in input().split()]
    ans = 'Yes'
    if len(H) == 1:
        print(ans)
        return

    for i in range(len(H)):
        if i == 0:
            H[i] -= 1
        elif H[i-1] - H[i] < 0:
            H[i] -= 1
        elif H[i-1] - H[i] >= 1:
            ans = 'No'
            break

    print(ans)


if __name__ == '__main__':
    q3()
n=int(input())
h=list(map(int,input().split()))
base=0
for i in h:
    if base>i:
        ans="No"
        break
    base=max(base,i-1)
else:
    ans="Yes"
print(ans)
N = int(input())

stairs = list(map(int, input().split(" ")))
min = 0

for i in range(N):
    stair = stairs[i]
    if min > stair:
        print("No")
        exit(0)
    if stair - 1 > min:
        min = stair - 1

print("Yes")
n=int(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')
N = int(input())
H = list(map(int, input().split()))
 
for i in range(N-1):
    if (H[i] < H[i+1]):
        H[i+1] -= 1
    if (H[i] > H[i+1]):
        print('No')
        exit()
 
print('Yes')
def main():
    N = int(input())
    H = list(map(int,input().split()))
    ans = "Yes"

    for i in reversed(range(N-1)):
        if H[i]>H[i+1]:
            H[i] -= 1
            if H[i]>H[i+1]:
                ans = "No"
                break
    print(ans)

if __name__ =="__main__":
    main()
N = int(input())
H = list(map(int,input().split()))
m = 0
for k in range(1,N):
    if H[k-1] > H[k]+1 or H[k] < m:
        print("No")
        exit(0)
    elif H[k-1] == H[k]+1:
        m = H[k]
print("Yes")
n = int(input())
li = list(map(int,input().split()))
flag = True
last = 0
for i,l in enumerate(li):
    #print(last,l)
    if i == 0:
        last = l-1
    if last > l:
        flag = False
        break
    elif last == l:
        last = l
    else:
        last = l-1
if flag:
    print('Yes')
else:
    print('No')
N = int(input())
H = list(map(int,input().split()))

count = 0
for i in H:
        if i+2 <= count:
            print('No')
            exit()
        else:
            count = max(i,count)
print('Yes')
n = int(input())
h = [int(i) for i in input().split()]
h.reverse()
next = h[0]
import sys
for i in h[1:]:
    if i - next > 1:
        print('No')
        sys.exit()
    elif i - next == 1:
        next = i - 1
    else:
        next = i
print('Yes')
n=int(input())
l=list(map(int,input().split()))

max=0
flag=0
for i in range(n):
    if l[i] >= max:
        max=l[i]
    else:
        if max-l[i] == 1:
            continue
        else:
            flag=1
            break

if flag == 1:
    print("No")
else:
    print("Yes")
n = int(input())
H = list(map(int, input().split()))
for i in range(n-1, 1, -1):
    if H[i - 1] - H[i] > 1:
        print('No')
        exit()
    elif H[i - 1] > H[i]:
        H[i - 1] -= 1
print('Yes')
n = int(input())
h = list(map(int, input().split()))
for i in range(n):
    if i == 0 or h[i - 1] < h[i]:
        h[i] -= 1
for i in range(n - 1):
    if h[i] > h[i + 1]:
        print('No')
        break
else:
    print('Yes')
n = int(input())
H = list(map(int, input().split()))
flag = True
H[0] -= 1
for i in range(1, n):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1
    elif H[i] - H[i - 1] < 0:
        flag = False

print('Yes' if flag == True else 'No')
# -*- coding: utf-8 -*-
n = int(input())
h = [int(i) for i in input().split()]

flag = True
for i in reversed(range(n - 1)):
    if h[i] - h[i + 1] == 1:
        h[i] -= 1
    elif h[i] > h[i + 1]:
        flag = False
if flag:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int, input().split()))
element = H[-1]
for i in reversed(H):
    if i > element:
        if i - 1 == element:
            continue
        else:
            print("No")
            exit()
    else:
        element = i
print("Yes")
n = int(input())
*h, = map(int, input().split())
for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] -= 1
print('Yes' if all(h[i] <= h[i+1] for i in range(n-1)) else 'No')
N = int(input())
H = list(map(int, input().split()))

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

flag = True
for i in range(N-1, -1, -1):

    if H[i] >= H[i-1]:
        pass
    elif H[i] + 1 == H[i-1]:
        H[i-1] -= 1

for i in range(N-1):
    if H[i] > H[i+1]:
        flag = False

if flag:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int, input().split()))
yesno = 'Yes'
p=0
for i in range(N-1):
    if H[i] < H[i+1]:
        p=0
    elif H[i] == H[i+1]:
        p=p
    elif H[i] - 1 == H[i+1]:
        p += 1
        if p == 2 :
            yesno = 'No'
            break
    else:
        yesno = 'No'
        break
print(yesno)
N = int(input())
arr = list(map(int, input().split()))

for i in range(N-1):
    if arr[i] == arr[i+1]+1:
        arr[i+1] +=1

    if arr[i] > arr[i+1]:
        print('No')
        exit()

print('Yes')
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

tmp_1 = H[np.where(H==H.max())[0].min():]
ans_1 = min(tmp_1) > max(H)-2

tmp2 = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")
n = int(input())
li_h = list(map(int, input().split()))
sum_ = 0
if len(li_h) == 1:
  print('Yes')
else:
  b = True
  max_ = li_h[0]
  for i in range(len(li_h)):
    if li_h[i] > max_:
      max_ = li_h[i]
    if max_ - li_h[i] > 1:
      b = False
  if b:
    print('Yes')
  else:
    print('No')
n = int(input())
h = list(map(int,input().split()))
for i in range(1,n):
  if h[i-1] >  h[i]:
    print('No')
    exit()
  elif h[i-1] + 1 <= h[i]:
    h[i] -= 1
print('Yes')
n = int(input())
lst = [0] + list(map(int, input().split()))
reach = False
for i in range(n):
  if reach:
    if lst[i + 1] - lst[i] <= -1:
      print('No')
      exit()
    elif lst[i + 1] - lst[i] >= 1:
      reach = False
  else:
    if lst[i + 1] - lst[i] == -1:
      reach = True
    elif lst[i + 1] - lst[i] <= -2:
      print('No')
      exit()
print('Yes')
n = int(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")
n = int(input())
li = list(map(int,input().split()))

li.reverse()

ope=0
flg=0

for i in range(1,n):
    chk = li[i]-li[i-1]
    if chk>1:
        print('No')
        flg = 1
        break
    elif chk==1:
        li[i]-=1
    else:
        continue

if flg==0:
    print('Yes')
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
  if (H[N-2-i] - 1) == H[N-1-i]:
    H[N-2-i] -= 1
  elif (H[N-2-i] - 1) < H[N-1-i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')
n = int(input())
h = list(map(int, input().split()))
h.reverse()

for i in range(n-1):
    diff = h[i+1] - h[i]
    if diff == 1:
        h[i+1] -= 1
    elif diff > 1:
        print('No')
        exit()
    else:
        pass

print('Yes')
n=int(input())
h=list(map(int,input().split()))
max=h[0]
flag=0
for i in h:
  if i>=max:
    max=i
  elif max-i>=2:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")
N=int(input())
H=list(map(int,input().split()))

if N==1:print('Yes')
else:
  MAX=H[0]
  ok=1
  for i in range(1,N):
    if H[i]>MAX:MAX=H[i]
    if H[i]<=MAX-2:
      ok=0
      break
  if ok==1:print('Yes')
  else:print('No')
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
Hs=(LI())
if n==1:
    print("Yes")
    sys.exit()
for i in range(1,n):
    #print(Hs[-i])
    if Hs[-i-1]==Hs[-i]+1:
        Hs[-i-1]-=1
    elif Hs[-i-1]>Hs[-i]+1:
        print("No")
        sys.exit()
if i==n-1:
    print("Yes")
N = int(input())
H = list(map(int, input().split()))
mx = H[-1]
for i in range(N-1, -1, -1):
  if H[i] <= mx:
    mx = min(mx, H[i])
  elif H[i]-1 <= mx:
    mx = min(H[i]-1, mx)
  else:
    print('No')
    exit()
print('Yes')
n=int(input())

h=[int(x) for x in input().split()]


flag = True

if n==1:
    print('Yes')
else:
    for i in range(n-1):
        l=h[i]
        r=h[i+1]
        if l < r:
            h[i+1]-=1
        else:
            h[i+1]=l
        if l > r:
            flag=False

    if flag:
        print('Yes')
    else:
        print('No')
N = int(input())
H = list(map(int,input().split()))

cnt =0
for i in range(N-1):
    if H[i] < H[i+1] :
        H[i+1] -= 1
    elif H[i] != H[i+1] :
        cnt += 1

if cnt != 0:
    print('No')
else :
    print('Yes')
import sys
N=int(input())
H=list(map(int,input().split()))
for i in range(1,N):
    if H[i-1]<=H[i]:
        pass
    elif H[i-1]==H[i]+1:
        H[i]+=1
    else:
        print("No")
        sys.exit()
print("Yes")
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'

if N > 1:
  H_rev = list(reversed(H))

  for i in range(N-1):
    if H_rev[i] < H_rev[i+1]:
      H_rev[i+1] -= 1

    if H_rev[i] < H_rev[i+1]:
      ans = 'No'
      break

print(ans)
n = int(input())
H = list(map(int,input().split()))
m = H[0]
for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] > H[i+1]:
        print("No")
        break
else:
    print("Yes")
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
    if H[i+1] - H[i] > 0:
        H[i+1] -= 1

for i in range(N-1):
    if H[i+1] < H[i]:
        print("No")
        exit()

print("Yes")
n=int(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')
N = int(input())
H = list(map(int,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')
     break
else:
 print('Yes')
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(1,len(arr)):
		if arr[i]>arr[i-1]:
			arr[i]-=1
		elif arr[i]<arr[i-1]:
			print("No")
			return
	print("Yes")
	return


main()


# 1 2 3 4 5
# 1 3 3 4 5
# 1 4 3 4 5
n = int(input())
h =list(map(int,(input().split())))

cnt = 0
for i in h:
    if i >= 1 and i > cnt:
        cnt = i - 1
    elif i >= 1 and i == cnt:
        pass
    else:
        print("No")
        break
else:
    print("Yes")
n=int(input())
h=list(map(int,input().split()))
if n==1:
    print("Yes")
    exit()
for i in range(1,n):
    if h[i]-h[i-1]<=-1:
        print("No")
        exit()
    elif h[i]-h[i-1]==0:
        pass
    elif h[i]-h[i-1]>=1:
        h[i]-=1
print("Yes")
def check():
  N = int(input())
  H = list(map(int, input().split()))
  for i in range(N-1):
    if H[i]>H[i+1]+1:
      return 'No'
    if H[i]==H[i+1]+1:
      H[i+1] += 1
  return 'Yes'
print(check())
n = int(input())
lh = [int(w) for w in input().split()]

cond = True
nh = lh[0]-1
for i in range(1, n):
    if lh[i] == nh:
        continue
    elif lh[i] > nh:
        nh = lh[i]-1
        continue
    else:
        cond = False
        break

print("Yes" if cond else "No")
#!/usr/bin/env python3

N = int(input())
lst = [int(h) for h in input().split()]

def judge():
    cur = lst[0]
    for i in range(1, N):
        if lst[i] < cur - 1:
            return False
        if lst[i] > cur:
            cur = lst[i]
    return True

if judge():
    print('Yes')
else:
    print('No')
N = int(input())
H = list(map(int, input().split()))

maxi = 0
for i in range(N):
    if H[i] > maxi:
        maxi = H[i]
    elif H[i] < maxi:
        if maxi - H[i] > 1:
            print("No")
            break
else:
    print("Yes")
import sys
n, *lst = map(int, sys.stdin.read().split())

a = lst[-1]
for i in lst[::-1]:
  if i > a + 1:
    print('No')
    quit()
  if i < a:
    a = i
else:
  print('Yes')
N = int(input())
H = list(map(int, input().split()))

fl = True
for i in range(1,N):
    if H[i]-H[i-1]>0:
        H[i] -= 1

for i in range(1,N):
    if H[i]-H[i-1]<0:
        fl = False
        break

print('Yes') if fl else print('No')
import sys

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

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

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

if h[n-2] <= h[n-1]:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
n = int(input())
h = [int(i) for i in input().split()] 

for i in reversed(range(1, n)):
    if h[i - 1] > h[i]:
        h[i - 1] -= 1
#print(h)
#print(sorted(h))
if h != sorted(h):
    print("No")
else:
    print("Yes")
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    H = list(map(int, input().split()))

    k = 0
    for i in range(N - 1):
        k += H[i + 1] - H[i]
        if k > 0:
            k = 0
        if k <= -2:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()
N=int(input())
S=list(map(int,input().split()))
Z=[0]*N
start=S[0]
for i in range(1,N):
    Z[i]=S[i]-start
    if S[i]>start:
        start=S[i]


flug=False
for i in range(N):
    
    if  Z[i]<=-2:
        print("No")
        exit()
        

print("Yes")
n = int(input())
h = list(map(int,input().split()))
maxer = 1
for i in range(n):
    if h[i] > maxer:
        maxer = h[i]-1
    elif h[i] == maxer:
        pass
    else:
        print("No")
        exit()
print("Yes")
n = int(input())
H = list(map(int, input().split()))
for i in range(n):
    #print(H)
    if i == 0:
        H[i] -= 1
    else:
        if H[i] < H[i-1]:
            print('No')
            exit()
        elif H[i] == H[i-1]:
            continue
        else:
            H[i] -= 1

#print(H)

for i in range(1, n):
    if H[i] < H[i-1]:
        print('No')
        exit()
else:
    print('Yes')
n = int(input())
h = list(map(int,input().split()))
ans = "Yes"

for i in range(1,n):
  if h[-i-1] > h[-i]:
    h[-i-1] = h[-i-1] - 1
  
  if h[-i-1] > h[-i]:
    ans = "No"
    break

print(ans)
N = int(input())
H = [int(i) for i in input().split()]

flag = False
for i in range(1,N):
    if H[i] - H[i-1] == 0:
        continue
    elif H[i] - H[i-1] < 0:
        flag = True
        break
    elif H[i] - H[i-1] > 0:
        H[i] -= 1

if flag:
    print("No")
else:
    print("Yes")
n = int(input())
h = list(map(int,input().split()))
j = h[0]

for i in range(1,n):
    if h[i] > j:
        h[i] -= 1
        j = h[i]
    else:
        pass

l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')
N=int(input())
H=list(map(int,input().strip().split()))

MAX=H[0]

for n in range(N):
    if MAX-H[n]>=2:
        print("No")
        break
    else:
        MAX=max(MAX,H[n])
else:
    print("Yes")
N=int(input())
H=list(map(int,input().split()))
a=H[0]
for i in range(1,N):
    if H[i]<a-1:
        print("No")
        break
    a=max(a,H[i])
else:
    print("Yes")
N=int(input())
H=list(map(int,input().split()))

max_h=H[0]

flg =0
for i in range(N):
    max_h =max(max_h,H[i])

    if max_h-1>H[i]:
        flg+=1

if flg!=0:
    print('No')
else:
    print('Yes')
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"
H[0] -= 1
for i in range(1, N):
    if H[i - 1] > H[i]:
        ans = "No"
        break
    if H[i - 1] < H[i]:
            H[i] -= 1

print(ans)
import sys
N = int(input())
H = list(map(int, input().split()))

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

print("Yes")
n = int(input())
h = list(map(int, input().split()))
tmp = h[-1]
ans = 'Yes'

for i in range(2,n+1):
    if tmp - h[-i] == -1:
        tmp = h[-i]-1
    elif tmp - h[-i] < -1:
        ans = 'No'
        break
    else:
        tmp = h[-i]

print(ans)
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
T = True
for i in range(1, N-1):
  if H[i-1]==H[i] and H[i]<=H[i+1]:
    continue
  elif H[i-1]<H[i] and H[i]-1<=H[i+1]:
    H[i] -= 1
    continue
  else:
    T = False
    break
print("Yes" if T else "No")
n = int(input())
s = list(map(int,input().split()))

M = 0
for i in range(n-1):
    if s[i] >= s[i+1] and s[i] > M:
        s[i] -= 1
    if s[i] < M:
        print("No")
        exit() 
    M = s[i]
    
if M <= s[-1]:
    print("Yes")
else:
    print("No")
#!/usr/bin/env python3

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

h.reverse()


ans = 0
for i in range(1, len(h)):
    if h[i-1]-h[i] >= 0:
        continue
    elif h[i-1]-h[i] == -1:
        h[i] -= 1
    else:
        print("No")
        exit()

print("Yes")
n = int(input())
a = list(map(int, input().split()))

pre = a[0]
ok = True
for i in range(n):
    if pre > a[i]:
        ok = False
        break
    if a[i] > pre:
        a[i] -= 1

    pre = a[i]

print('Yes' if ok else 'No')
N = int(input())
H = list(map(int, input().split()))
f = 0
maxtmp = H[0]
shave = 0
for i in range(N-1):
  if H[i]-1>H[i+1] or (H[i]-1==H[i+1] and shave==1):
    f = 1
    break
  elif H[i]-1==H[i+1] and shave==0:
    maxtmp = H[i+1]
    shave = 1
  elif H[i]==H[i+1]:
    pass
  else:
    maxtmp = H[i+1]
    shave = 0
if f == 0:
  print("Yes")
else:
  print("No")
n=int(input())
h=list(map(int,input().split()))

ans='Yes'
m=0
for i in range(1,n):
  m=max(m,h[i])
  if h[i]<m-1:
    ans='No'
    break
print(ans)
n = int(input())
a = list(map(int, input().split()))
 
for i in range(n-1):
    if a[i] == a[i+1]:
        continue
    if a[i] < a[i+1]:
        a[i+1] -= 1
    else:
        print("No")
        break
else:
    print("Yes")
import sys

n = int(input())
h = list(map(int, input().split(' ')))
max = 0
for i in range(len(h)):
    if max < h[i]:
        max = h[i]
    if h[i]+2 <= max:
        print('No')
        sys.exit()
print('Yes')
n = int(input())
h = list(map(int, input().split()))

for i in range(n):
    if i != n-1:
        if h[i] < h[i+1]:
            h[i+1] -= 1

        if h[i] > h[i+1]:
            print("No")
            exit()

print("Yes")
import sys
N=int(input())
L=list(map(int,input().split()))
L=list(map(int,list(reversed(L))))
for i in range(1,N):
  if L[i]>L[i-1]+1:
    print("No")
    sys.exit()
  elif L[i]==L[i-1]+1:
    L[i]=L[i]-1
print("Yes")
n = int(input())
h = list(map(int, input().split()))

f = True
maxh = None
for i in range(n - 1, 0, -1):
    if i == n - 1:
        continue
    if h[i] - h[i + 1] == 1:
        h[i] -= 1
    elif h[i] - h[i + 1] > 1:
        print("No")
        exit(0)
print("Yes")
# ans

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

if H == 1:
  print('Yes')
  exit()

for i in range(1, N):
  if H[i-1] == H[i]:
    pass
  elif H[i-1] < H[i]:
    H[i] -= 1
  else:
    print('No')
    exit()

print('Yes')
N = int(input())
HB = input().split(' ')
HB = [int(HB[i]) for i in range(N)]
Hs = [0]
for i in range(N):
  H = HB[i]
  if Hs[i] > H:
    print('No')
    break
  else:
   if Hs[i] == H:
     Hs.append(H)
   else:
     H = H - 1
     Hs.append(H)
else:
  print('Yes')
N=int(input())
H=list(map(int,input().split()))
min = 1e12
success = True
for i in range(N):
    if H[N-1-i] <= min + 1:
        if H[N-1-i] < min:
            min = H[N-1-i]
    else:
        success = False
        break
print('Yes' if success else 'No')