peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
l = list(map(int, input().split()))
ld = [l[i+1] - l[i] for i in range(n-1)]

ok = 1
if n > 1:
  ld[0] += 1
  for i in range(0,n-2):
    if ld[i+1] < -1:
      ok = 0
      break
    if ld[i+1] == -1 and ld[i] <= 0:
      ok = 0
      break

print(['No','Yes'][ok])
n = int(input())
h = list(map(int,input().split()))
ans = 'Yes'
dif = []
for i in range(n-2):
    if h[i+1]-h[i]>1:
        ans = 'No'
    elif h[i+1]-h[i]==1:
        h[i+1]-=1
print(ans)
n=int(input())
h=list(map(int,input().split()))
f=True

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

for i in range(1,n):
	if h[i]>=h[i-1]:
		f=True
	else:
		f=False
		break

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

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

ans = sorted(H)
if ans == H:
    print("Yes")
else:
    print("No")
n = int(input())
squeres = list(map(int, input().split()))
flag = True
before_down = 0
for i in range(n - 1):
    if squeres[i] > squeres[i + 1] and squeres[i] - 1 <= squeres[i + 1] and before_down == 0:
        before_down = 1

    elif not squeres[i] <= squeres[i + 1] and before_down == 1:
        flag = False
    
    else:
        if squeres[i] < squeres[i + 1]:
            before_down = 0
if flag:
    print("Yes")
else:
    print("No")
import sys
N = int(input())
h = list(map(int, input().split()))
count = 0
for i in range(N-1):
    diff = h[i+1] - h[i]
    if diff == -1:
        count += 1
        if i > 0:
            if h[i] == h[i-1]:
                print('No')
                sys.exit()
    elif diff < -1:
        print('No')
        sys.exit()        
    if count > 1:
        print('No')
        sys.exit()
print('Yes')
def main():
    input()
    t = list(map(int, input().split()))
    m = 0
    flg = True
    for i in range(len(t)):
        if 0 == i or i == len(t) - 1:
            continue
        if t[i-1] < t[i]:
            t[i] -= 1
        if t[i - 1] <= t[i] <= t[i + 1]:
            pass
        else:
            print('No', t[i])
            exit()
    print('Yes')

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()

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

#print(H)

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

print("Yes")
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(len(arr)-1):
		if arr[i]-1>arr[i-1]:
			# print(i)
			print("No")
			return
	print("Yes")
	return


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

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

for j in range(N-1):
    if H[j] > H[j+1]:
        print('No')
        break
else:
    print('Yes')
N = int(input())
H = list(map(int, input().split()))
ans = True
lis = {}
for i in H:
  if i in lis:
    lis[i] += 1
  else:
    lis[i] = 1
mine = min(H)
times = lis[mine]
for i in range(N):
  if mine < H[i]-1:
    ans = False
    break
  else:
    if H[i] == mine:
      times -= 1
    if times == 0 and i != N-1:
      if type(lis) == dict:
        lis = sorted(lis.items())
      del lis[0]
      mine = lis[0][0]
      times = lis[0][1]
if ans:
  print("Yes")
else:
  print("No")
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] - A[i+1]) >= 2:
            k  += 1
    q = 0
    for j in range(N-1):
        if (A[0] - A[j+1]) >= 2:
            q += 1
    if k < 1 and q == 0:
        print("Yes")
    else:
        print("No")
n = int(input())
h = list(map(int, input().split()))
ans = "Yes"
for i in range(n-1):
    if h[i] - h[n-1] > 1:
      ans = "No"
    else:
        if h[i] - h[i+1] > 1:
            ans = "No"
        else:
            continue
print(ans)
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
    if H[i] <= H[i+1]+1:
        continue
    else:
        print("No")
        break
print("Yes")
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
FL=False
Fx=-1
for i in range(n-1):
  if n==1:
    break
  if h[i]-h[i+1]==1:
    if FL:
      ans="No"
      break  
    else:
      FL=True
      Fx=h[i]
  if h[i]-h[i+1]>1:
    ans="No"
    break  
  else:
    if h[i]>=Fx:
      FL=False
print(ans)
N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(N-1):
    if H[i] - 1 > H[i+1]:
        ans = "No"
        break
if max(H) != H[N-1]:
    if max(H) > H[N-1] + 1:
        ans = "No"
print(ans)
N = int(input())
H = list(map(int,input().split()))

ok = True
for i in range(1,N):
  l = H[i-1] - 1
  r = H[i]
  
  if l <= r:
    H[i-1] -= 1
    continue
  else:
    ok = False
    break
      
if ok:
  print('Yes')
else:
  print('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')
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] = (H[i] - 1)

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


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

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

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

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
h = rl()
temp = 0
for i in h:
    if temp > i: 
        print('No')
        exit()
    temp = i
else:
    print('Yes')
n = int(input())
h = list(map(int, input().split()))
if min(h) == h[n-1] and set(h) != 1: print("No")
else: print("Yes")
n = int(input())
h = list(map(int, input().split()))

f = True
maxh = None
for i in range(1, n):
    if h[i - 1] <= h[i]:
        continue
    if h[i - 1] - h[i] > 1 or maxh is not None and maxh != h[i - 1]:
        f = False
        break
    maxh = h[i - 1]
    h[i - 1] -= 1

if f:
    print("Yes")
else:
    print("No")
n = int(input())
lst = [int(i) for i in input().split()]
min_value = min(lst)
lst = [i - 1 if i != min_value else i for i in lst]
lst_be = lst[:n-1]
lst_af = lst[1:]
lst = [1 if af < be else 0 for be, af in zip(lst_be, lst_af)]
if sum(lst) > 0:
	print ('No')
else:
	print ('Yes')
#python3
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

flag = True
for i in range(n-1):
  if not (h[i] <= h[i+1]):
    flag = False

if flag:
  print('Yes')
else:
  print('No')
N = int(input())
Hs = [int(i) for i in input().split()]

is_Yes = True
for i in range(1, N-1):
    if Hs[i-1] == Hs[i]:
        continue
    elif Hs[i] > Hs[i-1]:
        Hs[i] -= 1
    else:
        is_Yes = False
        break

if is_Yes:
    print('Yes')
else:
    print('No')
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")
from sys import exit
n = int(input())
hh = list(map(int, input().split()))

ans = True
down = False
for i in range(1, n):
    if hh[i-1] <= hh[i]:
        continue
    elif not down:
        hh[i-1] -= 1
        if hh[i-1] <= hh[i] and (i==n-1 or hh[i-1] <= hh[i]):
            down = True
            continue
    print('No')
    exit()
print('Yes')
N = int(input())
H = list(map(lambda h: int(h), input().split(" ")))

impossible = False
for i in range(len(H) - 1):
  if H[i] - H[i+1] >= 2:
    impossible = True

print("No") if impossible else 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]<temp:
      print("No")
      break
    temp=max(temp,h[i]-1)
  else:
    print("Yes")
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(sorted(H))
if H != sorted(H):
  no = True
print(['Yes','No'][no])
n=int(input())
A=list(map(int,input().split()))
for i in range(n-1):
  if A[i+1]-A[i]<-2:
    print("No")
    exit()
print("Yes")
n = int(input())
l = [int(x) for x in input().split()]
#print(n, l)

a = 0
for i in range(n-1):
    if l[i] <= l[i+1]:
        continue
    else:
        if l[i] - 1 == l[i+1]:
            a += 1
#print(a)

if a <= 1:
    print('Yes')
else:
    print('No')
#! python3
#  solve_136C.py

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

Frag = 1

for i in range(0,N-1):
    if H[i]  == H[i+1] + 1:
        H[i] -= 1
    elif H[i] <= H[i+1]:
        pass
    else:
        Frag = 0
        break

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

ht=h[-1]
ans="Yes"
for i in reversed(h):
  if 0 <= i <= ht+1:
    ht = i
  else:
    ans="No"
    break
    
print(ans)
N=int(input())
arr=list(map(int,input().split()))
ans=1
kari=1
for i in range(N-1):
    kari=max(kari,arr[i]-1)
    print(i,kari,ans)
    if kari>arr[i+1]:
        ans=0
        print(i,kari,ans)
        break


    
if ans==0:
    print("No")
else:
    print("Yes")
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
        if H[i]>H[i+1]:
            print("No")
            break
else:
    print("Yes")
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")
N = int(input())

h = [int(x) for x in input().split()]
x = h[0]
i = 1
k = 0
for _ in [0]*(N-1):
  y = h[i]
  i += 1
  if (y - x == -1) and k == 1 :
    print('No')
    exit()
  elif y - x == -1:
    x = y
    k = 1
  elif y - x >= 0:
    x = y
    k = 0
  else:
    print(x, y)
    print('No')
    exit()

print('Yes')
N = int(input())
List = list(map(int,input().split()))
flag = 0
for i in range(N-1):
  if List[i]>List[i+1]+1:
    print('No')
    exit()
  elif List[i]==List[i+1]+1 and flag == 1:
    print('No')
    exit()
  elif List[i]==List[i+1]+1:
    flag = 1
print('Yes')
n=int(input())
a=list(map(int,input().split()))
frag=1
frag2=1
for i in range(n-1):
  print(i,frag,frag2)
  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()))
ans = "Yes"
for i in range(n-1):
    if h[i] > h[i+1]:
        h[i] -= 1

for j in range(n-1):
    if h[j] > h[j+1]:
        ans = "No"
        break
print(ans)
n = int(input())
h = list(map(int, input().split()))
ans = ''
for i in range(1, n -1):
  if -1 <= h[i] - h[i - 1] and -1 <= h[i + 1] - h[i]:
    next
  else:
    ans = 'No'
    break
if ans == '':
  ans = 'Yes'
print(ans)
n = int(input())
h = list(map(int,input().split()))

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

if (ans == 1):
    print("Yes")

else :
    print("No")
N = int(input())
H = [int(i) for i in input().split()]

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

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

if flag == 0:
	print("No")
else:
	print("Yes")
# ABC136 C;Build Srairs

N = int(input())
l = list(map(int,input().split()))
ans = 'Yes'

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

        if l[i+1] < l[i] or l[i-1]> l[i]:
            ans = 'No'
            break
#print(l)
print(ans)
n = int(input())
h = list(map(int, input().split()))

ans = 0

if n == 1:
	print('Yes')

else:
	for i in range(n-2):
		if h[i] + 1 == h[i + 1]:
			print('Yes')
			break
		elif h[i] == h[i + 1]:
			continue
		else:
			print('No')
			break
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

L = sorted(H)
if H == L:
    print('Yes')
else:
    print('No')
n = int(input())
h = list(map(int, input().split()))

ans = 0

if n == 1:
	print('Yes')

else:
	for i in range(n-1):
		if h[i] + 1 == h[i + 1]:
			print('Yes')
			break
		elif h[i] == h[i + 1]:
			continue
		else:
			print('No')
			break
import sys

n = int(input())
s = list(map(int, input().split()))
nums = []
mx, cnt = 0, 0
s = s[::-1]
if n == 1:
    print("Yes")
    sys.exit(0)
elif n == 2:
    if s[1] - s[0] >= -1:
        print("Yes")
        sys.exit(0)
    else:
        print("No")
        sys.exit(0)
else:
    for i in range(n - 2):
        if s[i] < s[i + 1] < s[i + 2]:
            print("No")
            sys.exit(0)
print("Yes")
N=int(input())
H=list(map(int,input().split()))
m=0
for i in range(N-1):
    if H[i] > m+1: print('No'); exit()
    m=max(m,H[i])
print('Yes')
n = int(input())
h = list(map(int,input().split()))
import sys

for i in range(n-1,1,-1):
    if max(h[:i])>h[i]+1:
        break
    print(f"{i+1}:ok!")
else:
    print("Yes")
    sys.exit()
print("No")
n = int(input())
high = list(map(int,input().split()))

a = True

for x in range(n-1):
  if high[x] - high[x+1] >= 2:
    a = False
    break
    
for x in range(n-2):
  if high[x]>high[x+1]>high[x+2]:
    a = False
    break
if a:
  print("Yes")
  
else:
  print("No")
n = int(input())
h = [int(i) for i in input().split()]
min = h[- 1]
index = - 1
for i in range(n):
    if h[- 1 - i] < min:
        min = h[- 1 - i]
        index = - 1 - i
for i in h[:index]:
    if i >= min + 2:
        print("No")
        break
else:
    print("Yes")
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()))
for i in range(n - 2):
    if (h[i] - h[i + 1] >= 2) or (h[i + 1] - h[i + 2] >= 2) or (h[i] - h[i + 2] >= 2):
        print('No')
        exit()
print('Yes')
n = int(input())
l = [int(x) for x in input().split()]
#print(l)

for i in range(1,n)[::-1]:
    if l[i-1] - 1 == l[i]:
        l[i] = l[i] + 1
    else:
        continue
    
#print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')
n = int(input())
h = list(map(int,input().split()))
mh = h[0]
for i in range(1,n):
    if h[i-1] > h[i]:
        if h[i-1] - 1 == h[i] and h[i] >= mh:
            h[i-1] -= 1
        else:
            print("No")
            exit()
    mh = h[i-1]

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

if n == 1 or (n == 2 and hh[0] - 1 <= hh[1]):
    print('Yes')
    exit()

for i in range(n-1,0,-1):
    if hh[i] >= hh[i-1]:
        continue
    else:
        hh[i-1] -= 1
        if hh[i] >= hh[i-1]:
            continue
        print(i)
        print('No')
        exit()
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
        else:
            print("No")
            exit()
    elif h[i] > h[i + 1]:
        print("No")
        exit()
if h[n - 2] <= h[n - 1]:
    print("Yes")
else:
    print("No")
N=int(input())
H=list(map(int,input().split()))
flg = True
for i in range(N-1):
    if H[i+1] - H[i] <= -2:
        print("No")
        flg = False
        break
    if i != 0:
        if H[i+1] - H[i] == -1 and H[i] - H[i-1] >= 2:
            print("No")
            flg = False
            break
if flg == True:
    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:
        hh[i] -= 1
        if hh[i] <= hh[i+1] and (i==0 or hh[i-1] <= hh[i]):
            down = True
            continue
    print('No')
    exit()
print('Yes')
n = int(input())
h = list(map(int,input().split()))
flg = True

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

v=0
l=0

for i in range(n-2):
    if h[i]>h[i+1] and h[i+1]>h[i+2]:
        v=v+1
    if h[i]-h[i+1]<-1:
      l=l+1
if v==0 and l==0:
    print("Yes")
else:
    print("No")
N = int(input())
li = list(map(int, input().split()))

ans = 'Yes'

for index, i in enumerate(li):
  if index + 1 > len(li) - 1:
    break

  if i - li[index+1] >= 2:
    ans = "No"

  if index + 2 > len(li) - 1:
    continue

  if i > li[index+1] > li[index+2]:
    ans = "No"

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

for i in range(len(H)-1):
  if H[i] > H[i+1]:
    H[i] -=1
    if H[i] > H[i+1] or H[i] < ma:
      print('No')
      exit()
  if i == 0 or H[i] > H[i-1]:
    H[i] -= 1
  ma = H[i]
   
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
for j in range(n-1):
  if h[j]>h[j+1]:
    print('No')
    exit()
else:
  print('Yes')
N=int(input())
H=list(map(int,input().split()))
s=0
t=0
for i in range(N-1):
  if H[i]-H[i+1]>=2:
    break
  if H[i]>H[i+1] and H[i]-H[i+1]<2:
    s+=1
    t+=1
  else:
    s=s
    t+=1
if s>=2 or t<N-1:
  print("No")
else:
  print("Yes")
n=int(input())
L=list(map(int, input().split()))
cnt=0
L.insert(0,0)
for i in range(1,n):
	if L[i]>L[i+1]:
		s=L[i]-L[i+1]
		cnt+=1
		if L[i-1]>L[i]-1:
			print('No')
			exit()
		if s>=2:
			print('No')
			exit()

if cnt>=2:
	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]:
    pass
  else:
    if h[i] == h[i+1] -1:
      h[i+1] -= 1
    else:
      exit(print('No'))

print('Yes')
def solve():
    ans = "Yes"
    for i in range(N-1):
        if H[i] - H[i+1] == 1:
            H[i] -= 1
        elif H[i] - H[i+1] > 1:
            continue
        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+1] - (H[i]-1) > 1:
        print("Yes")
        exit()
print("No")
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
H = sorted(h)
for j in range(n-1):
    if H[j] > H[j+1]:
        ans = "No"
        break
print(ans)
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:
        h -= 1
    print(prev, H[i], h, peek)
    if h < prev:
        ret = False
        break
    prev = h
print("Yes" if ret else "No")
n=int(input())
hlis=list(map(int,input().split()))
ans=1
for i in range(n-1):
	if hlis[i]>hlis[i+1]:
		if hlis[i]-hlis[i+1]>1:
			ans=0
		elif i>0 and hlis[i-1]>hlis[i]:
			ans=0
print("Yes" if ans==1 else "No")
n = int(input())
aaa = list(map(int, input().split(' ')))
before = 0
ans = 'Yes'
for i in range(n-1):
    if aaa[i] == aaa[i+1] + 1:
        aaa[i] -= 1
for i in range(n-1):
    if aaa[i] > aaa[i+1]:
        ans = 'No'
print(ans)
n = int(input())
h =list(map(int, input().split()))

flg = True

for i in range(n-1):
    if h[i] < h[i+1]:
        flg = True
    
    if h[i] > h[i+1] and h[i]-1 == h[i+1] and flg:
        h[i] -= 1
        flg = False

# print(h)

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

s = 0
for i in range(1,len(a)):
  if a[i-1]-a[i]==1:
    s+=1
   
if s>=2:
  print("No")
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] + 1:
    ans = 'No'
    break
    
print(ans)
N = int(input())
H = map(int,input().split())
min = 0
m = 0
ans = 'Yes'
print("m i")
for i in H:
  if m == 0:
    m = i
    continue
  print(m,i)
  if m <= i + 1:
    m = max(m,i - 1)
  else:
    ans = "No"
    break
print(ans)
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:
            H[i] -= 1
            continue
        if H[i-1] == H[i]:
            flg = 0
            break
        H[i] -= 1
if flg == 1:
    print('Yes')
elif flg == 0:
    print('No')
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]+1) < A[i]:
            k  += 1
    if k <= 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(n-1):
        if h[i]-1 > h[i+1]:
                print('No')
                exit()
        elif h[i]-1 == h[i+1]:
                h[i] -=1
                if h[i-1] > h[i]:
                        print('No')
                        exit()
print('Yes')
n = int(input())
h = list(map(int, input().split()))
h = h[::-1]
count = 0
for i in range(1, n):
    if h[i]-h[i-1]==1:
        h[i]+=-1
    elif h[i]-h[i-1]>=2:
        print('NO')
        exit()
print('YES')
# C - Build Stairs

N = int(input())
H = [int(h) for h in input().split()]
ans = 'Yes'
mx = 0
for i in range(N - 1):
    if H[i + 1] + 1 < H[i]:
        ans = 'No'
        break
    if H[i + 1] < H[i]:
        H[i] -= 1
    if H[i] < mx:
        ans = 'No'
        break
    mx = max(mx, H[i])

print(ans)
n = int(input())
h = [int(i) for i in input().split()]
min = h[- 1]
index = - 1
for i in range(n):
    if h[- 1 - i] < min:
        min = h[- 1 - i]
        index = - 1 - i
if min + 2 in h[:index]:
    print("No")
else:
    print("Yes")
n = int(input())
h = list(map(int,input().split()))
ans = 'Yes'
dif = []
for i in range(n-2):
    if h[i+1]-h[i]>1: ans = 'No'
print(ans)