peterverebics/CodeNet_Python_118 huggingface dataset:
def main():
    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')
            return
    print('Yes')

if __name__ == "__main__":
    main()
n = int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n-1):
    if a[i] < a[i+1]:
        a[i+1] -=1
count = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        count+=1
if count == 0:
    print("Yes")
else:
    print("No")
import numpy as np

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

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2
tmp = H[1:] - H[:-1]
ans_2 = all(tmp > -2)

print("Yes") if ans_1 & ans_2 else print("No")
N = int(input())
H = list(map(int,input().split()))
ans = 'Yes'
for i in range(N-1):
    if H[i+1] -H[i] >= 1:
        H[i+1] -= 1
    if H[i]-H[i+1] >= 1:
        ans = 'No'
        break
print(ans)
n = int(input())
l = list(map(int, input().split()))

tmp = 0
for h in l:
  if h > tmp:
    tmp = h-1
  if h < tmp:
    print('No')
    break
else:
  print('Yes')
n = int(input())
h = list(map(int, input().split()))
max_ = h[0]

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i] >= 2:
        print("No")
        exit()
print("Yes")
from functools import reduce
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
print('Yes' if reduce(lambda x, y: x <= y, H) else 'No')
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(len(arr)-1):
		if arr[i]>arr[i+1]:
			arr[i]-=1
	for i in range(len(arr)-1):
		if 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()))

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

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

if F:
    print("Yes")
else:
    print("No")
import sys
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
for i in range(1,n-1):
    if h[i-1]<=h[i]<=h[i+1]:
        pass
    else:
        h[i]-=1
        if h[i-1]<=h[i]<=h[i+1]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")
def main():
    N = int(input())
    H = list(map(int, input().split(" ")))
    flag = True
    for i in range(N - 1):
        if H[i] - H[i + 1] <= 0:
            H[i + 1] -= 1
    for j in range(N - 1):
        if H[j + 1] - H[j] < 0:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
n = int(input())
h = list(map(int, input().split()))
for i in range(n-1):
    if h[i+1]-h[i] > 1:
        print('No')
        exit()
print('Yes')
n = int(input())
h =list(map(int, input().split()))

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

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

print("Yes")
import sys

n = int(sys.stdin.readline())
h = list(map(int, sys.stdin.readline().split()))

ans = 'Yes'
for i in range(n - 1):
    if h[i + 1] - h[i] < 0:
        ans = 'No'
        break
    elif h[i + 1] - h[i] <= 1:
        h[i + 1] -= 1
print(ans)
n=(int)(input())
a=list(map(int, input().split(" ")))
for i in range(len(a) - 1):
  if a[i] > a[i + 1] + 1:
    print("No")
    break
else:
  print("Yes")
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(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()))
mx=max(h)
for i in range(n):
    if mx-h[i]>=2:
        print('No')
        exit()
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-=1
print(ans)
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range(N -1):
        if A[i + 1] < A[i]:
            k  += (A[i] - A[i +1])
    if k <= 1:
        print("Yes")
    else:
        print("No")
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

prev = H.popleft()

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

for i in range(N-1):
    cor = H.popleft()
    if prev - cor < -1:
        print('No')
        exit()
    
    prev = cor


print('Yes')
import sys

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

cnt = 0
for i in range(N-1):
    if(H[i] > H[i+1]):
        tmp = H[i] - 1
        if(tmp != H[i+1] or cnt > 0):
            print('No')
            sys.exit()
        cnt += 1
print('Yes')
N = int(input())
H = list(map(int,input().split()))
check = 0

for i in range(0,N-1):
  if(H[i+1] < H[i]):
    H[i+1] = H[i]
  elif(H[i]-H[i+1] >= 2):
    check = 1
    
if(check == 1):
	print("No")
else:
	print("Yes")
def myAnswer(N:int,H:list) -> str:
   pre = H.pop(0)
   for h in H:
      if(pre > h):
         if((pre - h) == 1):
            pre = pre - 1
         else:
            return "No"
      else:
         pre = h
   return "Yes"


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   H = list(map(int,input().split()))
   print(myAnswer(N,H[:]))
if __name__ == '__main__':
   main()
from sys import exit
 
N = int(input())
h = list(map(int,input().split()))
 
pre = 0
for i in range(N-1):
    if h[i] <= h[i+1]:
        pre = h[i]
    else:
        if h[i]-1 <= h[i+1]:
            if pre > h[i]-1:
                print("No")
                exit(0)
            else:
                pre = h[i]-1
        else:
            print("No")
            exit(0)

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

for i in range(n-1):
    if h[i] > h[i + 1]:
        h[i] -= 1
#print(h)
#print(sorted(h))
if h != sorted(h):
    print("No")
else:
    print("Yes")
n=int(input())
h=list(map(int,input().split()))

cnt=0

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

if cnt==0:
    print('Yes')
if cnt>1:
     print('No')
if cnt==1:
    for j in range(1,n):
        if h[j-1]>h[j]:
            if h[j-1]-h[j]==1:
                print('Yes')
            else:
                print('No')
N=int(input())
H=list(map(int, input().split()))
no = False
for i in range(N-1):
#  print(H[i],H[i+1])
  if H[i]>H[i+1]+1:
    no = True
    break
  elif H[i]==H[i+1]+1:
    H[i] -= 1
#print(H)
if H != H.sort():
  no = True
print(['Yes','No'][no])
def main():
    n = int(input())
    h = list(map(int, input().split()))

    pre = 0
    for i in range(n):
        if h[i] >= pre + 1:
            h[i] -= -1
        if h[i] < pre:
            print('No')
            break
        pre = h[i]
    
    print('Yes')
                

if __name__ == '__main__':
    main()
N = int(input())
H = list(map(int, input().split()))

flg = 1
for i in range(N-1):
    if H[i] - H[i+1] >= 2:
        flg = 0
        break
    if H[i] - H[i+1] == 1:
        if i == 0:
            continue
        if H[i-1] == H[i]:
            flg = 0
            break
        H[i] -= 1
if flg == 1:
    print('Yes')
else:
    print('No')
N = int(input())
H = list(map(int, input().split()))

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

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

while i < n:
    if h[i] < h[i-1]:
        h[i-1] -= 1
    elif h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass

    i += 2

l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
if N == 2:
    if H[0] > H[1]:
        ans = "No" 
else: 
    for i in range(N-2):
        if H[i] - H[i+2] >= 2:
            ans = "No"
print(ans)
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
    if h[i]>h[i+1]:
        h[i]-=1
        if h[i]>h[i+1]:
            print("No")
            quit()
print("Yes")
n = int(input())
arr = list(map(int, input().split()))
for i in range(n-1, 0, -1):
    if arr[i]>arr[i-1]:
        arr[i-1]-=1
        if arr[i]>arr[i-1]:
            print('No')
            break
else:
    print('Yes')
N = int(input())
H = list(map(int, input().split()))
flag = True
reach = False

for n in range(N - 1):
  if H[n] > H[n + 1]:
    if n >= 1 and H[n] - 1== H[n + 1] and H[n] - 1 >= H[n - 1]and reach == False:
      reach = True
      H[n] -= 1
    elif n == 0 and H[n] - 1== H[n + 1] and reach == False:
      reach = True
      H[n] -= 1
    else:
      flag = False
if flag:
  print("Yes")
else:
  print("No")
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()
f = h[0]
b = False
for hi in h[1:]:
    if hi > f:
        f = hi
        b = False
    elif hi == f - 1 and not b:
        f = hi
        b = True
    elif hi == f:
        b = True
    else:
        print("No")
        quit()
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+1]:
        print("No")
        sys.exit()
        
print("Yes")
def ok(hs):
    m = 0
    for h in hs:
        if h > m + 1:
            return False
        m = max(m, h)
    return True

n = int(input())
print('Yes' if ok(map(int, input().split())) else 'No')
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')
n = int(input())
s = list(map(int, input().split()))
mx, cnt = 0, 0
for i in s[::-1]:
    if i >= mx:
        mx = i
        cnt += 1
    else:
        pass
    if cnt >= 2:
        break

print("Yes") if cnt < 2 else print("No")
N = int(input())
H = [int(i) for i in input().split()]
#  N = 5
#  H = [1, 2, 1, 1, 3]
#  N = 4
#  H = [1, 3, 2, 1]
#  N = 5
#  H = [1, 2, 3, 4, 5]
#  N = 1
#  H = [1000000000]
ret = True
prev = H[0]
peek = 0
for i in range(1, N - 1):
    peek = H[i + 1]
    h = H[i]
    if h - peek == 1:
        h -= 1
    # print(prev, H[i], h, peek)
    if h < prev:
        ret = False
        break
    prev = h
print("Yes" if ret else "No")
import sys
n=int(input())
h=list(map(int,input().split()))

for i in range(1,n-1):
    if h[i-1]<=h[i]<=h[i+1]:
        pass
    else:
        h[i]-=1
        if h[i-1]<=h[i]<=h[i+1]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")
n = int(input())
hs = [int(elem) for elem in input().split()]

res = []
flag = 0
for i, h in enumerate(hs):
  if i == 0 :
    res.append(0)
  else:
    if res[-1] < 0 and (h - hs[i-1]) < 0:
      flag = 1
      break
    else:
      res.append(h - hs[i-1])
  
if flag == 0:
  print("Yes")
else:
  print("No")
N = int(input())
S = list(map(int, input().split()))
for a in range(N-1):
    if S[a] > S[a+1]:
        if S[a] - S[a+1] <= 1:
            continue
        else:
            print("No")
            exit()
for a in range(N-2):
    if S[a] > S[a+2]:
        if S[a] - S[a+2] <= 1:
            continue
        else:
            print("No")
            exit()

print("Yes")
n=int(input())
a=list(map(int,input().split()))
frag=1
frag2=1
for i in range(n-1):
  if a[i]-a[i+1]==1:
    if frag2==1 and frag==1:
      frag2=0
    elif frag2==0:
      frag=0
      break
    elif frag==2:
      frag=0
      break
  elif a[i]-a[i+1]>1:
    frag=0
    break
  elif a[i]==a[i+1]:
    frag=2
  elif frag==2:
    frag=1
if frag!=0:
  print('Yes')
else:
  print('No')
n=int(input())
h=list(map(int,input().split()))
f=1
for i in range(n-2):
    if h[i+1]-h[i]<-1 or h[i+2]-h[i+1]<-1:
        f=0
        break
    if h[i+1]-h[i]<=0 and h[i+2]-h[i+1]<0:
        f=0
        break
       
if f:
    print("Yes")
else:
    print("No")
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    h = list(map(int,ipti().split()))

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

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

    print('Yes')

if __name__ == '__main__':
    main()
n = int(input())
hlis = list(map(int, input().split()))
d = 0
for i in range(n-1):
    d = max(d, hlis[i] - hlis[i+1])
if d > 2:
    print('No')
else:
    print('Yes')
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

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

tmp = 0
flag = False

for h in h_list:

    if tmp == 0:
        tmp = h
        continue

    if tmp > h:
        tmp = h
        if flag:
            print("No")
            exit(0)
        else:
            flag = True
    else:
        tmp = h
        flag = False

print("Yes")
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2):
    if h[i] < h[i + 1] and h[i + 1] > h[i + 2]:
        if h[i] <= h[i + 1] - 1 and h[i + 1] - 1 == h[i + 2]:
            h[i + 1] -= 1
for i in range(n - 1):
    if h[i] > h[i + 1]:
        print("No")
        exit()
print("Yes")
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()
f = h[0]
b = False
for hi in h[1:]:
    if hi >= f:
        f = hi
        continue
    elif hi == f - 1 and not b:
        f = hi
    else:
        print("No")
        quit()
    if hi == f:
        b = True
print("Yes")
input()
H = [int(i) for i in input().rstrip().split(' ')]
N = len(H)

for i in range(0,N):
    a = H[i]
    b = H[i - 1] if i > 0 else 0
    n = H[i + 1] if i < N -1 else 10**9
    print(i,"#",b,a,n)
    if n == a - 1:
        if b == a:
            print("No")
            break
        else:
            H[i] -= 1
    elif n < a - 1:
            print("No")
            break
else:
    print("Yes")
print(H)
n=int(input())

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

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


print('Yes')
n = int(input())
lst = [int(i) for i in input().split()]
last_value = lst[-1]
if sum([1 if i > last_value + 1 else 0 for i in lst]) > 0:
	print ('No')
else:
	print ('Yes')
n = int(input())
H = list(map(int,input().split()))
print ("Yes") if H[0] < H[-1] or n == 1 else print ("No")
n = int(input())
h = list(map(int, input().split()))
sv = h[n-1]
ok = True
for i in range(n-1):
    if h[i] - sv >= 2:
        ok = False

if ok:
    print('Yes')
else:
    print('No')
n = int(input())
h = list(map(int, input().split()))[::-1]
INF = float('inf')
last = INF
for i in h:
    if last >= i:
        last = i
    elif i - last == 1:
        last -= 1
    else:
        print("No")
        exit(0)
print("Yes")
import sys
N=int(input())
L=list(map(int,input().split()))
for i in range(N):
  if i==0:
    L[i]-=1
  elif i==N-1:
    if L[i-1]>L[i]:
      print("No")
      sys.exit()
  else:
    if L[i]>L[i+1]:
      L[i]-=1
    if L[i-1]>L[i]:
      print("No")
      sys.exit()
print("Yes")
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

j = []
count = 0
prev = H.popleft()

for i in range(N-1):
    cor = H.popleft()
    if cor - prev < -1:
        print('No')
        exit()
    elif cor - prev == -1:
        j.append(cor - prev)
        count += 1
    else:
        j.append(cor - prev)

    if count >= 2:
        print('No')
        exit()

    prev = cor

print('Yes')
n = int(input())
l = list(map(int, input().split()))
m = max(l)
num = l.index(m)
for i in range(num, len(l)):
    if l[i] + 2 <= m:
        print("No")
        exit()
print("Yes")
def main():
    N = int(input())
    H = [int(i) for i in input().split()]
    for i in range(N-1)[::-1]:
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                return print("NO")
    print("YES")


if __name__ == '__main__':
    main()
# C - Build Stairs

n = int(input())
h = list(int(x) for x in input().split())

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

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

ans = 'Yes'

for i in range(N-1):
    if h[i] <= h[i+1]:
        ans = 'Yes'
        continue
        print(i)
    if h[i] == (h[i+1]-1):
        ans = 'Yes'
        continue
    else:
        ans = 'No'

print(ans)
n = int(input())
h = [int(e) for e in input().split()]
flg = "Yes"
equal = 0
for i in range(n-1):
    if equal:
        if h[i] > h[i+1]:
            flg = "No"
            break
    else:
        h[i] -= 1
   
        if h[i+1] < h[i]:
            flg = "No"
            break
        elif h[i+1] == h[i]:
            equal = 1

        else:
            equal = 0
print(flg)
N = int(input())
A = list(map(int,input().split()))
first = 0
for i in range(N):
    m = max(first,A[i])
    if A[i] < first-1:
        print("No")
        exit()

print("Yes")
N = int(input())
H = [int(x) for x in input().split()]

for i in range(N-1):
    if H[i] - H[i+1] == 1:
        H[i] -= 1
flg=True
for i in range(N-1):
    if H[i] - H[i+1] == 1:
        flg=False
        break
ans = 'Yes' if flg else 'No'
print(ans)
N = int(input())
H = list(map(int, input().split()))[::-1]
high = H[0]
for i in range(1, N):
    if high - H[i] < -1:
        print("No")
        exit()
    else:
        high = H[i]
print("Yes")
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
if max(a) - min(a) <= 1:
  print("Yes")
  exit(0)
for i in range(N - 1):
  if a[i + 1] - a[i] < 0:
    a[i] -= 1
  if a[i] - a[i + 1] < 0:
    a[i + 1] -= 1
for i in range(N - 1):
  if a[i + 1] < a[i]:
    print("No")
    exit(0)
print("Yes")
n = int(input())
stair = input().split(' ')
flag = 0

for i in range(0, n - 1):
  if (int(stair[i]) < int(stair[i+1])):
    stair[i+1] = int(stair[i+1]) - 1
    if (int(stair[i]) > int(stair[i+1])):
      print("No")
      exit;


print("Yes")
from sys import exit
n = int(input())
hh = list(map(int, input().split()))

ans = True
down = False
for i in range(n-1):
    if hh[i] <= hh[i+1]:
        continue
    elif not down and hh[i] - 1 == hh[i+1]:
        down = True
        continue
    else:
        print('No')
        exit()
        break
print('Yes')
def solve():
    ans = "Yes"
    for i in range(N-1):
        if H[i+1] >= H[i]:
            continue
        elif H[i] - H[i+1] == 1:
            H[i] -= 1
        else:
            ans = "No"
            break
    print(ans)

if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))  
    solve()
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
    if h[i]>h[i+1]:
        h[i]-=1
if max(h)-min(h)==1:
    print("Yes")
    quit()
for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        quit()
print("Yes")
N=int(input())
W=list(map(int,input().split()))
for i in range(N-1,0,-1):
  if W[i-1]-1>W[i]:
    print("No")
    exit()
    if W[i-1]+1==W[i]:
      W[i]-=1
print("Yes")
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

prev = H.popleft()

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

for i in range(N-2):
    cor = H.popleft()
    if prev - cor < -1:
        print('No')
        exit()
    prev = cor

cor = H.popleft()

if cor - prev < 0:
    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-1):
    if h[i]-1<temp:
      print("No")
      break
    temp=max(temp,h[i])
  else:
    print("Yes")
n = int(input())
h = list(map(int, input().split()))
for i in range(1,n):
    if h[i-1] > h[i]:
        h[i-1] -= 1
print("Yes") if h == sorted(h) else print("No")
N = int(input())
H = list(map(int,input().split()))
if N>1:
    for i in range(N-1,0,-1):
        if H[i] < H[i-1] :
            H[i-1] -= 1
if sorted(H) != H:
    print('NO')
else:
    print('YES')
N = int(input())
H = list( map(int,input().split()) )


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

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

print('Yes')
n = int(input())
hs = list(map(int, input().split()))

result = 'Yes'

for i in range(1, n - 1):
    cur, prev, nex = hs[i], hs[i - 1], hs[i + 1]
    if cur < prev or cur > nex:
        cur -= 1
        hs[i] = cur

    if not prev <= cur <= nex:
        result = 'No'
        break


print(result)
N=int(input())
H=list(map(int,input().split()))
base=0
for h in H:
    if base>h:
        print("No")
        break
    base=h-1
else:
    print("Yes")
n=int(input())
list=list(map(int,input().split()))
for i in range(1,n):
    if list[i-1]>list[i]:
        list[i-1]-=1
        if list[i]==max(list[0:i]):
             continue
        else:
            print("No")
            break
else:print("Yes")
import numpy as np
N = int(input())
l = np.array(list(map(int,input().split())))
ans = 'Yes'
M = l[0]

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

    if l[i]< M-1:
        ans ='No'
        break
print(ans)
n=int(input())
h=list(map(int,input().split()))
for i in range(n):
    ans="Yes"
    if i>0 and h[i-1]-h[i]>1:
        ans="No"
print(ans)
import sys
input = sys.stdin.readline

def main():
    N=int(input())
    H=list(map(int,input().split()))
    s=0
    if N==1:
        print('Yes')
    else:
        for i in range(0,N-1):
            if H[i]>H[i+1]:
                s+=H[i]-H[i+1]
        if s<2:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()
import sys

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

for i in range(1,N-1):
    if not(H[i-1] <= H[i] <= H[i+1]):
        tmp = H[i] - 1
        if not(H[i-1] <= tmp <= H[i+1]):
            print('No')
            sys.exit()
        H[i] = tmp
    H[i] -= 1
print('Yes')
from sys import exit
 
N = int(input())
h = list(map(int,input().split()))
 
pre = 0
for i in range(N-1):
    if h[i] <= h[i+1]:
        pre = h[i]
    else:
        if h[i] - h[i+1] == 1:
            if pre > h[i]-1:
                print("No")
                exit(0)
            else:
                pre = h[i]-1
        else:
            print("No")
            exit(0)

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

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

else:
        print('No')
n = int(input())
h = list(map(int, input().split()))

ans = 'Yes'
is_e = False
i = 0
while i < n-1:
    if h[i+1] == h[i]:
        is_e = True
    elif h[i+1] > h[i]:
        is_e = False
    elif h[i+1] == h[i]-1 and is_e is False:
        is_e = True
    else:
        ans = 'No'
        break
    i += 1
print(ans)
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
    if H[i] > H[i+1]:
        H[i] -= 1
        if H[i] > H[i+1]:
            break
        
for i in range(N-1):
    if H[i] > H[i+1]:
        print('No')
        break
else:
    print('Yes')