peterverebics/CodeNet_Python_118 huggingface dataset:
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  H=list(map(int,pin().split()))
  H.reverse()
  for i in range(N-1):
    if H[i]>=H[i+1]:
      pass
    elif H[i]==H[i+1]-1:
      H[i+1]-=1
    else:
      print("No")
      break
  else:
    print("Yes")
  return 

main()
n = int(input())
a = list(map(int, input().split()))
b = a[::-1]
for i in range(1, n):
  if b[i] - b[i-1] > 1:
    print("No")
    exit()
  elif b[i] - b[i-1] == 1:
    b[i] -= 1
else:
  print("Yes")
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
yn=0
for i in range(n-1):
    if h[i]+1<=h[i+1]:
        h[i+1]-=1
    if h[i]>h[i+1]:
        yn=1
        break
if yn==1:
    print("No")
else:
    print("Yes")
n,*l=map(int,open(0).read().split())
t=s=0
for i in l:
  if i<t: s=1
  if i>t: t=i-1
print('YNeos'[s::2])
N = int(input())
H = list(map(int, input().split()))

prev = H[-1]
for i in range(N - 2, -1, -1):
    #print(i)
    if not H[i] <= prev:
        if not H[i] - 1 <= prev:
            print('No')
            quit()
        else:
            H[i] -= 1
            prev = H[i]
    else:
        prev = H[i]
print('Yes')
n = int(input())
h = list(map(int, input().split()))
 
for i in reversed(range(1,n)):
    if h[i] < h[i-1]:
        h[i-1] -= 1
        if h[i] < h[i-1]:
            print("No")
            exit()
print("Yes")
N = int(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')
n=int(input())
b =list(map(int,input().split()))

b.reverse()

for i in range(1,n):

    if (b[i] > b[i-1]): b[i] += -1

    if b[i] > b[i-1] : print('No');exit() 


print('Yes')
n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
ht = h[-1]
for i in reversed(range(n-1)):
    if ht == h[i]-1:
        h[i]-=1
    elif ht < h[i]-1:
        print('No')
        exit()
    ht = h[i]
print('Yes')
n = int(input())
a = list(map(int,input().split()))

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

judge = 0
for i in range(n):
  if a[i] < judge:
    print("No")
    break
  judge = max(judge, a[i]-1)
else:
  print("Yes")
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    H = list(map(int, input().split()))

    for i in range(1, n):
        if H[i - 1] < H[i]:
            H[i] -= 1

    for j in range(1, n):
        if H[j - 1] > H[j]:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()
n=int(input())
h=list(map(int,input().split()))
count=0
for i in h:
    if count>i:
        print("No")
        break
    count=max(count,i-1)
else:
    print("Yes")
import sys

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

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

ans = "Yes"

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

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


for i in li:
    if i < max_n - 1:
        ans = "No"
        break
    max_n = max(i,max_n)
print(ans)
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
h = na()
hpre = h[-1]
for hi in h[:-1][::-1]:
    if hi <= hpre:
        hpre = hi
    elif hi == hpre + 1:
        hpre = hi - 1
    else:
        print("No")
        quit()
print("Yes")
import sys
N = int(input())
L = list(map(int,input().split()))
for i in range(N-1,0,-1):
    if L[i-1] > L[i]:
        if L[i-1] - 1>L[i]:
            print('No')
            sys.exit(0)
        L[i-1]-=1
print('Yes')
N = int(input())
H = list(map(int,input().split()))

hardle = 0
ans = "Yes"
for i in H:
  if hardle>i:
    ans = "No"
    break
  else:
    if i>hardle:
      hardle=i-1
print(ans)
N=int(input())
H=list(map(int,input().split()))
hlow=[H[i]-1 for i in range(N)]
a=[hlow[0]]
flag=True
for i in range(1,N):
    if a[i-1]<=hlow[i]:
        a.append(hlow[i])
    elif a[i-1]<=H[i]:
        a.append(H[i])
    else:
        print('No')
        flag=False
        break

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

if N==1:
    print('Yes')
else:
    for i in range(N-1):
        if H[N-i-2]>= H[N-i-1]+2:
            print('No')
            exit()
        elif H[N-i-2]==H[N-i-1]+1:
            H[N-i-2]-=1
    
    for j in range(N-1):
        if  H[i]>H[i+1]:
            print('No')
            exit()
    print('Yes')
n=int(input())
h=list(map(int,input().split()))
temp=0
if n==1:
  print("Yes")
else:
  for i in range(0,n):
    if h[i]<temp:
      print("No")
      break
    temp=max(temp,h[i]-1)
  else:
    print("Yes")
n = int(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')
N = int(input())
A = list(map(int, input().split()))



for i in range(N-1):
    #print(i, max, N, A[i], A[i+1])
    if A[i] - A[i+1] >=2:
        print('No')
        break
    
    if A[i] - A[i+1] ==1 and i >=2 and A[i-1] >= A[i]:
        print("No")
        break
    
    if i ==0 or A[i] > A[i-1]:
        A[i] -=1
        
else:
    print('Yes')
N = int(input())
H = [int(i) for i in input().split()]

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

if sorted(H)==H:
    print('Yes')
else:
    print('No')
N = int(input())
H = [int(h) for h in input().split()]
H.reverse()

if N == 1:
    print("Yes")
else:
    is_clear = True
    for n in range(N-1):
        if H[n] >= H[n+1]:
            pass
        elif H[n+1] - H[n] == 1:
            H[n+1] -= 1
        else:
            is_clear = False
            break

    if is_clear:
        print("Yes")
    else:
        print("No")
#python3
n=int(input())
h=[int(i) for i in input().split()]

def solve():
  h[0]-=1
  for i in range(1,n):
    if h[i] > h[i-1]:
      h[i]-=1
    elif h[i] == h[i-1]:
      pass
    else :
      print('No')
      return 0
  return 1
    

if solve():
  print('Yes')
N = int(input())
H = list(map(int, input().split()))
for i in range(N - 1, 0, -1):
	if H[i] < H[i - 1] - 1:
		print('No')
		break
	elif H[i] == H[i - 1] - 1:
		H[i - 1] -= 1
else:
	print('Yes')
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    H=[int(_) for _ in input().split()]
    H[0]-=1
    for i in range(1,n):
        if H[i-1]<H[i]:H[i]-=1
        elif H[i-1]>H[i]:
            print("No")
            break
    else:print("Yes")
if __name__=='__main__':
    main()
n = int(input())
h = list(map(int, input().split()))
m = 0
flag = True
for n in h:
    if m < n:
        m = n
    elif n <= m - 2:
        flag = False
        break
if flag:
    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]:
        H[i] -= 1
    elif H[i - 1] > H[i]:
        print('No')
        exit()
print('Yes')
from sys import exit
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1,0,-1):
  if h[i-1] > h[i]:
    h[i-1] -= 1
  if h[i-1] > h[i]:
    print("No")
    exit(0)
print("Yes")
n = int(input())
h = list(map(int,input().split()))
flg = "Yes"
pre = -999
for i in range(1,n):
    #print(h[i])
    if pre <= h[i]-1 :
        pre = h[i]-1
    elif pre <= h[i]:
        pre = h[i]
    else:
        flg = "No"
        break
    
print(flg)
N = int(input())
H = list(map(int, input().split()))
# H[N-2],H[N-3],...,H[0]について
for i in range(N - 2, -1, -1):
    if H[i] > H[i + 1] + 1:
        print("No")
        exit()
    if H[i] == H[i + 1] + 1:
        H[i] -= 1
print("Yes")
n=int(input())
h=list(map(int,input().split()))
 
h=h[::-1]
for i in range(1,n):
  if h[i]-h[i-1]>1:
    print("No")
    exit(0)
  elif h[i]-h[i-1]==1:
    h[i]-=1
print("Yes")
N = int(input())
H = list(map(int,input().split()))
for i in reversed(range(N-1)):
    if(H[i] <= H[i+1]):
        continue
    elif(H[i]-1 == H[i+1]):
        H[i] -= 1
    else:
        print("No")
        exit()
print("Yes")
N = int(input())

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

H = 0
ck = 0

for i in range(N):
  a = List[i]
  if a >= H:
    if a-1 >= H:
      H = a -1
    else:
      H = a
  else:
    ck = 1

print("Yes" if ck == 0 else "No")
n = int(input())
a = list(map(int, input().split()))
flg = 0
a[0] -= 1
for i in range(1,n):
  if a[i] >= a[i-1] + 1:
    a[i] -= 1
  elif a[i] < a[i-1]:
    flg = 1
if flg == 1:
  print('No')
else:
  print('Yes')
n = int(input())
h = list(map(int, input().split()))

h.reverse()

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

    elif h[i] == h[i+1] - 1:
        h[i+1] -= 1

    else:
        print('No')
        exit()

print('Yes')
def solve():
    n = int(input())
    h = list(map(int, input().split()))
    right = h[len(h)-1]
    flag = True
    for i in reversed(h):
        if i <= right:
            right = i
            continue
        elif i-1 == right:
            continue
        else:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')


solve()
n = int(input())
al = list(map(int, input().split()))
cnt = len(al)
tmp = al[cnt-1]

for i in range(cnt-1, 1, -1):
    if al[i-1] - tmp >= 2:
        print("No") 
        exit()
    elif al[i-1] - tmp == 1:
        tmp = al[i-1]-1
    else:
        tmp = al[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]:
        if H[i] <= H[i+1] + 1:
            H[i+1] += 1
        else:
            print('No')
            break
else:
    print('Yes')
N = int(input())
height = list(map(int,input().split()))
for i in range(N-1,0,-1):
    n = height[i] - height[i-1]
    if n <= -2:
        print("No")
        exit()
    elif n == -1:
        height[i-1] -= 1
print("Yes")
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"
for i in range(N-1):
  dif = H[i+1] - H[i]
  if dif <= -2:
    ans = "No"
  elif dif == -1:
    H[i+1] += 1
print(ans)
# https://atcoder.jp/contests/abc136/tasks/abc136_c

n = int(input())
nums = [int(i) for i in input().split()]

for i in range(1, n):
    if nums[i] == nums[i - 1] - 1:
        nums[i] += 1
    if nums[i] < nums[i - 1]:
        print('No')
        break
else:
    print('Yes')
n = int(input())
h = list(map(int, input().split()))
h = h[::-1]
f = True
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    if h[i] < h[i+1]:
        f = False
        break
if f: print('Yes')
else: print('No')
n = int(input())
H = list(map(int, input().split()))
flag = True
highest = 0
for i in range(n):
    if H[i] > highest:
        highest = H[i]
    else:
        if highest > H[i] + 1:
            flag = False
            
print('Yes' if flag == True else 'No')
N = int(input())
Hlist = list(map(int,input().split()))
sign = 1
Answer = 'Yes'
for i in range(len(Hlist)-1):
    H1 = Hlist[i]
    H2 = Hlist[i+1]
    if H1 > H2:
        if H1 - H2 == 1 and sign == 1:
            Hlist[i] -= 1
            sign =0
        else:
            Answer = 'No'
            break
    if H1 < H2:
        sign = 1
print(Answer)
import sys
N = int(input())
H = list(map(int, input().split()))

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


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

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

for i in range(n - 1):
    if data[i] > data[i + 1]:
        #print("i:{0}".format(i))#
        print("No")
        exit()

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

ans = "Yes"
t = h[0]
for i in range(1,n):
    t = max(h[i-1],t)
    if h[i] - t <= -2:
        ans = "No"
        break

print(ans)
N=int(input())
Hi=list(map(int,input().split()))

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

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

print('Yes')
n=int(input())
h=list(map(int,input().split()))
a=h[0]
for i in range(1,n-1):
    a=max(h[i],a)
    b=h[i+1]
    if a-b>=2:
        print('No')
        exit(0)
print('Yes')
n=int(input())
h=list(map(int,input().split()))

check=0
for i in h:
	if check-1>i:
		print("No")
		exit()
	check=max(check,i)
print("Yes")
# https://atcoder.jp/contests/abc136/tasks/abc136_c

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

past_H = 0
can_substract = False

for i in range(1, N - 1):

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

    if (H_list[i] - H_list[i + 1] == 1) and (H_list[i] - H_list[i - 1] < 1):
        print('No')
        exit()

    if H_list[i] - H_list[i - 1] >= 1:
        H_list[i] -= 1
        continue

print('Yes')
N=int(input())
H=list(map(int,input().split()))
flag=True
for i in range(1,N):
    if H[i]>H[i-1]:
        H[i]-=1
    elif H[i]==H[i-1]:
        pass
    elif H[i]<H[i-1]:
        flag=False
print("Yes" if flag else "No")
N = int(input())
H = list(map(int, input().split()))

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

if H == sorted(H):
    print("Yes")
else:
    print("No")
import sys
n = int(input())
h = list(map(int,input().split()))
for i in range(n-1,0,-1):
    if h[i]-h[i-1]>=0:
        pass
    elif h[i]-h[i-1]==-1:
        h[i-1] -= 1
    else:
        break
else:
    print("Yes")
    sys.exit()
print("No")
N = int(input())
A = list(map(int, input().split()))
A.reverse()
ans = "Yes"
for i in range(N-1):
  if A[i] >= A[i+1]:
    continue
  elif A[i] == A[i+1] - 1:
    A[i+1] = A[i]
  else:
    ans = "No"
print(ans)
n = int(input())
h_ls = list(map(int, input().split()))

target = []
for i in range(1,n):
    d = h_ls[i] - h_ls[i-1]
    if d > 0:
        target = []
    elif d == 0:
        target.append(i-1)
    else:
        target.append(i-1)
        for j in target:
            h_ls[j] -= 1
        target = []
res = 'Yes'
for i in range(1,n):
    d = h_ls[i] - h_ls[i-1]
    if d < 0:
        res = 'No'
print(res)
N = int(input())
H = list(map(int,input().split()))
H.reverse()

check = True

for i in range(N-1):
  if H[i] >= H[i+1]:
    continue
  else:
    if H[i+1] - H[i] > 1:
      check = False
      break
    else:
      H[i+1] -= 1
      
if check:
  print("Yes")
else:
  print("No")
n = int(input())
a = list(map(int, input().split()))
tmp = a[0] - 1
ans = "Yes"
for i in range(1, n):
    if a[i] < tmp:
        ans = "No"
        break
    elif a[i] == tmp:
        tmp = a[i]
    else:
        tmp = a[i] - 1
print(ans)
N = int(input())
H = list(map(int,input().split()))
tmp = -999999
for i in range(N):
    if tmp <= H[i]-1:
        tmp = H[i] -1
    elif tmp <= H[i]:
        tmp = H[i]
    else:
        print('No')
        break
else:
    print('Yes')
N = int(input())
Hs = list(map(int,input().split()))

ans = 'Yes'
for i in range(N-1, 0, -1):
  if Hs[i-1] > Hs[i]:
    if Hs[i-1] - Hs[i] == 1:
      Hs[i-1] -= 1
      continue
    else:
      ans = 'No'
      break
print(ans)
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
  exit(0)
if H[0]-H[1]>1:
  print('No')
  exit(0)
else:
  H[0]-=1
for i in range(1,N-1):
  if H[i+1]>=H[i]:
    if H[i]-H[i-1]>=1:
      H[i]-=1
    continue
  else:
    if H[i]-H[i+1]==1 and H[i]-1-H[i-1]>=0:
      H[i]-=1
      continue
    else:
      print('No')
      exit(0)
print('Yes')
import sys
N=int(input())
H=list(map(int,input().split()))
H.insert(0,0)
for i in range(N):
  if(H[i+1]<H[i]):
    print("No")
    sys.exit()
  if(H[i+1]>H[i]):
    H[i+1]-=1
print("Yes")
def main():
    n = int(input())
    h = list(map(int,input().split()))

    for i in range(1,n)[::-1]:
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1]-1
        if h[i-1] > h[i]:
            print('No')
            return 0
    print('Yes')

if __name__ == '__main__':
    main()
n = int(input())
h = list(map(int,input().split()))
lowest = h[0]-1
for i in range(1,n):
  if h[i] < lowest:
    print("No")
    quit()
  else:
    lowest = max(lowest,h[i]-1)
print("Yes")
import sys
N = int(input())
boxes = list(map(int,input().split()))
prev = 10**9+1
for box in boxes[::-1]:
    if prev - box > -1:
        prev = box
    elif prev - box == -1:
        prev = box -1
    else:
        print("No")
        sys.exit()
print("Yes")
n = int(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")
        break
else:
    print("Yes")
n = int(input())
h = list(map(int,input().split()))

ans = 1
m = h[0]
for i in range (n):
    if (h[i] > m):
        m = h[i]
    elif (m-h[i] >= 2):
        ans = 0
        break

if (ans == 1):
    print("Yes")
else :
    print("No")
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *h = map(int, read().split())
h = h[::-1]
for i, (bf, af) in enumerate(zip(h, h[1:])):
    if bf + 1 < af:
        print('No')
        exit()
    if bf < af:
        h[i + 1] -= 1
print('Yes')
n = int(input())
listH = list(map(int, input().split()))

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


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


for i in range(n-1):
  if h[n-1-i]<h[n-i-2]-1:
    print('No')
    exit()
  elif h[n-1-i]==h[n-i-2]-1:
    h[n-i-2]=h[n-i-2]-1

print('Yes')
def LI():
	return [int(s) for s in input().split()]
  
N = int(input())
A_s = LI()

success_flag = True

for i in range(N-2,-1,-1):
  if A_s[i+1] < (A_s[i]-1):
    success_flag = False
    break
  elif  A_s[i+1] < A_s[i]:
    A_s[i]=A_s[i]-1

print('Yes') if success_flag else print('No')
N=int(input())
H=list(map(int,input().split()))
ans=0
for i in H:
    if ans>i:
        print('No')
        exit()
    ans=max(ans,i-1)
else:
    print('Yes')
n = int(input())
h = list(map(int, input().split()))

for i in range(1,n):
    if h[i] >= h[i-1]: continue
    if h[i] <= h[i-1] - 2: print('No'); break
    h[i] += 1
else: print('Yes')
n = int(input())
h = list(map(int,input().split()))
t1, t2 = h[0]-1, h[0]
for i in range(1, n):
	if h[i] < t1:
		print("No")
		exit()
	else:
		t1, t2 = max(h[i]-1, t1), max(h[i], t2)
print("Yes")
#https://atcoder.jp/contests/abc136/tasks/abc136_c

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

flag = 'Yes'
for i in reversed(range(n - 1)):
    if h[i+1] - h[i] < 0 and h[i+1] - h[i] > -2:
        h[i] -= 1
    elif h[i+1] - h[i] <= -2:
        flag = 'No'
        break
print(flag)
n,*h=map(int,open(0).read().split())
h.reverse()
base=h[0]
flg=True
for i in h:
  if i > base:
    if i-1 > base:
      flg=False
      break
  elif i < base:
    base = i
print("Yes" if flg else "No")
from sys import stdin
def main():
    input=stdin.readline 
    n=int(input())
    H=[int(_) for _ in input().split()]
    H[0]-=1
    for i in range(1,n):
        if H[i-1]<H[i]:H[i]-=1
        elif H[i-1]>H[i]:
            print("No")
            break
    else:print("Yes")
if __name__=='__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
b=0
for i in a:
  if b>i:print("No");exit()
  b=max(b,i-1)
print("Yes")
N=int(input())
H=list(map(int,input().split()))

C=[H[0]]
for i in range(1,N):
    if H[i-1]!=H[i]:
        C.append(H[i])
        
for i in range(len(C)-1):
    if C[i]>C[i+1]:
        C[i]-=1

F=True
for i in range(len(C)-1):
    F&=(C[i]<=C[i+1])

if F:
    print("Yes")
else:
    print("No")
import sys
n=int(input())
A = [int(i) for i in input().split()]
#A =list(map(int,input().split()))
mi = 0
for i in range(n):
    if mi < A[i]:
        mi = A[i]-1
    elif mi == A[i]:
        mi = A[i]
    elif A[i]-mi < 0 :
        print('No')
        sys.exit()
print('Yes')
n = int(input())
h = list(map(int, input().split()))
mn = 0
ans = "Yes"
for i in h:
    if i <= mn - 2:
        ans = "No"
    else:
        mn = max(mn, i)
print(ans)
def main():
    N = int(input())
    H = [int(i) for i in input().split()]
    pre = H[-1]
    for i, h in enumerate(H[::-1], start=1):
        if i == 1:
            continue
        if h - pre > 1:
            return print("No")
        elif h - pre == 1:
            pre = h - 1
        else:
            pre = h
    print("Yes")


if __name__ == '__main__':
    main()
n=int(input())
h=list(map(int,input().split()))
for i in reversed(range(n-1)):
  if h[i]>h[i+1]:
    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 = [int(i) for i in input().split()]


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

    print("No")
    break

else:
    print("Yes")
n = int(input())
h = [int(x) for x in input().split()]

lmax = h[0]
for i in range(1, n-1):
   lmax = max(lmax, h[i])
   if lmax - h[i+1] >= 2:
      print('No')
      exit()

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