peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
h = list(map(int, input().split()))
#b = list(map(int, input().split()))
flag = [0]*n
for i in range(n-1):
    if h[i]-h[i+1] >= 1:
        h[i] -= 1
        flag[i] = 1


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

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

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

if H!=sorted(H):
  print("No")
else:
  print("Yes")
n=int(input())
l=list(map(int,input().split()))
if(n==1):
    print("Yes")
else:
    if(l[0]<l[-1]):
        print("Yes")
    else:
        print("No")
N = int(input())
A = list(map(int,input().split()))
 
# 後ろ向きに考える
# 各要素は基本的に大きくしたいので、そのまま、もしくは
# うまくいかない場合にのみ、1減らす
ans = 'Yes'
for i in range(N-1, 0, -1):
  print(A[i], A[i-1])
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

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

flag = True
for i in range(n-1):
    if a[i] > a[i+1]:
        a[i]-=1
        if a[i] > a[i+1]:
            frag = False
if flag:
    for i in range(n-1):
        if a[i] > a[i+1]:
            flag = False

print("Yes") if flag else print("No")
n=int(input())
h=list(map(int,input().split()))
for i in range(n):
    try:
        if h[i]-1>=h[i+1]:
            h[i]=h[i]-1
    except IndexError:
        pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *h = map(int, read().split())

if len(h) == 1:
    print('Yes')
    exit()
l = [max(h[0]-1,1)]
for i in range(1, n):
    if 1 <= h[i] - l[i - 1] <= 2:
        l.append(h[i] - 1)
    elif h[i] - l[i - 1] == 0:
        l.append(h[i])
    else:
        print('No')
        exit()

print('Yes')
n = int(input())
x = list(map(int,input().split()))
y = []
for i in range(n-2):
  y.append(x[i]-x[i+1])
count = 0
for i in y:
  if i >=1:
    count+=1
if count<=1:
  print("Yes")
else:
  print("No")
N = int(input())
H = list(map(int,input().split()))

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

for i in range(N-1):
    if H[i] > H[i+1]:
        print("No")
        exit()
        
print("Yes")
N=int(input())
S=list(map(int,input().split()))
Z=[0]*N

for i in range(1,N):
    Z[i]=S[i]-S[i-1]


flug=False
for i in range(N):
    
    if  Z[i]<=-2:
        print("No")
        exit()
        
    elif Z[i]==-1 and flug==False:
        flug=True
    elif Z[i]==-1 and flug==True:
        print("No")
        exit()
    
print("Yes")
N = int(input())
M = list(map(int,input().split()))

ans = "Yes"
limit = 0

for i in range(N-1) :
    c = M[i+1]-M[i]
    if 0 <= c :
        limit = M[i]
        continue
    elif c == -1 and limit <= M[i]-1:
        limit = M[i]-1
        continue
    else :
        ans = "No"
        break

print(ans)
n,*h=map(int,open(0).read().split())
for i in range(n-1)[::-1]:
  if h[i+1]<h[i]:
    h[i]-=1
    if h[i+1]<h[i]:
      print('NO')
      exit()
print('YES')
n=int(input())
h=list(map(int,input().split()))
for i in range(n):
    try:
        if h[i]>h[i+1]:
                h[i]=h[i]-1
    except IndexError:
        pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
            if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])
H.reverse()

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

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())
num = list(map(int, input().split()))
left = num[0]
for i in num:
  right = i
  if 0 < abs(right-left) <= 1:
    left = max(right, left)
  elif right-left == 0:
    left += 1
  else:
    print("No")
    exit()
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(N):

    if (past_H - H_list[i] > 1) or (past_H - H_list[i] == 1 and can_substract == False):
        print('No')
        exit()

    if past_H <= H_list[i]:

        if past_H == H_list[i]:
            can_substract = False
        else:
            can_substract = True

    else:
        can_substract = False

    past_H = H_list[i]

print('Yes')
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
print(ans)
N = int(input())
height = list(map(int,input().split()))
for i in range(N-1,0,-1):
    print(i)
    n = height[i] - height[i-1]
    if n <= -2:
        print("No")
        exit()
    elif n == -1:
        height[i-1] -= 1

print("Yes")
n=int(input())
l=list(map(int,input().split()))
if n!=1:
  m=l[0]
  cnt=0
  for i in range(n-1):
    if l[i]>l[i+1]+1:
      print('No')
      exit()
    if l[i+1]<m:
      m=min(m,l[i+1])
      cnt+=1
    if cnt==2:
      print('No')
      exit()
print('Yes')
N = int(input())
H = list(map(int, input().split()))

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

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

    if H[i] <= H[i+1]:
        pass
    elif H[i] == H[i+1] + 1:
        H[i] -= 1
    else:
        flag = False

if flag:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int,input().split()))
H.sort(reverse=True)

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())
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')
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()
    elif prev - cor == -1:
        prev = cor -1
    else:
        prev = cor

cor = H.popleft()

if cor - prev< 0:
    print('No')
    exit()

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

if all(H[i-1] <= H[i] for i in range(1, n)):
    print('Yes')
else:
    print('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:
            pass
        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()))
for i in range(n-1):
    if h[i+1]== h[i]+1:
        h[i+1] -= 1
    elif h[i+1] < h[i]:
        print('No')
        break
else:
    print('Yes')
n=int(input())
lst=list(map(int, input().split()))
for i in range(n-1):
    if lst[i]>lst[i+1]:
        lst[i]-=1
if lst==sorted(lst):
    print('Yes')
else:
    print('No')
n = int(input())
li = list(map(int,input().split()))
li.append(10**9+1)
f = 0
if li[0] > li[1] + 1:
    print("No")
    exit()
elif li[0] - 1 == li[1]:
    li[0] = li[0] - 1
for i in range(1,n-1):
    if li[i-1] <= li[i] and li[i] <= li[i+1]:
        continue
    elif li[i-1] <= li[i] - 1 and li[i] - 1 <= li[i+1]:
        li[i] = li[i] - 1
    else:
        print("No")
        f = 1
        break
if f == 0:
    print("Yes")
n = int(input())

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

tmp = lis[0]
for i in range(1, n):
    if tmp == lis[i]:
        tmp = lis[i]
    elif tmp == lis[i]-1:
        tmp = lis[i] -1
    elif tmp <= lis[i]:
        tmp = lis[i]
    elif tmp >= lis[i] -1:
        tmp = lis[i] -1
    else:
        print("No")
        exit()
        
print("Yes")
n = int(input())
li = list(map(int,input().split()))
li.append(10**9+1)
f = 0
if li[0] > li[1] + 1:
    print("No")
    exit()
elif li[0] - 1 == li[1]:
    li[0] = li[0] - 1
for i in range(1,n-1):
    if li[i-1] <= li[i] and li[i] <= li[i+1]:
        continue
    elif li[i-1] <= li[i] - 1 and li[i] - 1 <= li[i+1]:
        li[i] = li[i] - 1
    else:
        print("No")
        f = 1
        break
if f == 0:
    print("Yes")
print(li)
n = int(input())
h = list(map(int, input().split()))
tmp = h[-1]
ans = 'Yes'

for i in range(2,n+1):
    print(tmp, h[-i],i)
    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()))
flag = "Yes"
for i in range(1,n):
    #print(h[i])
    if h[i] >= h[i-1]: #単調増加またはイコール
        pass

    else: #減少してる
        h[i-1] -= 1
        if h[i-2] > h[i-1]:
            flag = "No"
            break
        elif h[i] < h[i-1]:
            flag = "No"
            break
        else:
            pass
print(flag)
n = int(input())
h = list(map(int, input().split()))
for i in range(n-1):
  diff = h[i] - h[i+1]
  if i == n-2:
    if diff > 1 :
      print("No")
      exit()
  else:
    if abs(diff) > 1 :
      print("No")
      exit()
print("Yes")
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 1):
    if h[i + 1] - h[i] < 0:
        print("No")
        exit()
    elif h[i + 1] - h[i] == 1:
        h[i + 1] -= 1
print("Yes")
#!/usr/bin/env python3

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

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

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

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

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

print("Yes")
n = input()

num = list(map(int, input().split()))
jadge = "true"

for i in range(len(num) - 1):
  if num[i] > num[i + 1]:
    num[i] = num[i] - 1
    if num[i] < num[i - 1]:
      jadge = "false"
    else:
      jadge = "true"
  else:
    continue

if jadge == "true":
  print("Yes")
else:
  print("No")
n = int(input())
s = list(map(int,input().split()))

M = 0
for i in range(n-1):
    if s[i] > s[i+1]:
        s[i] -= 1
    if M > s[i]:
        print("No")
        exit()
    M = s[i]
    
if M <= s[-1]:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int,input().split()))
can = True

for i in range(1, N - 1):
    if H[i] > H[i + 1]:
        if H[i] - 1 > H[i + 1]:
            can = False
            break
        else:
            H[i] -= 1
            if H[i - 1] > H[i]:
                can = False
                break

print(['No', 'Yes'][can])
N=int(input())
H=list(map(int,input().split()))

flag=False

for i in range(N-1):
    if H[i]<H[i+1]:
        flag=True
    if H[i]<H[i+1]:
        flag=True
        H[i]-=1
    else: 
        flag=False
        break

print("Yes" if flag else "No")
n=int(input()) 
c=list(map(int, input().split())) 

if n == 1:
    print('Yes')
    exit()
if n == 2:
    if c[0] > c[1] + 1:
        print('No')
        exit()
if n >= 3:
    for i in range(n-2):
        if c[i] > c[i+1] + 1:
            print('No')
            exit()
        if c[i] <= c[i+1] + 1 and c[i] > c[i+2] + 1:
            print('No')
            exit()

print('Yes')
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]:
    H[i]-=1
  elif H[i]==H[i+1]:
    continue
  else:
    print("No")
    exit()
for i in range(N-1):
  if H[i]>H[i+1]:
    print("No")
    exit()
print("Yes")
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

H.reverse()
if H.index(max(H)) == 0:
    print("Yes")
else:
    print("No")
N=int(input())
H=list(map(int,input().split()))
num=0
for i in range(0,N-1):
    if H[i]==H[i+1]+1 and H[i-1]<H[i]:
        H[i]=H[i]-1
    else:
        H[i]=H[i]
for n in range(0,N-1):
    if H[n+1]<H[n]:
        num=num+1
if num==N-1:
    print("No")
else:
    print("Yes")
n = int(input())
H = list(map(int,input().split()))
ans = "Yes"
H_min = 0

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

highest = H[0] - 1

for i in range(N-1):
    if (H[i+1] <= H[i] and H[i+1]<= H[i]-1 and H[i+1]<=highest):
        print('No')
        exit()
    highest = max(highest, H[i]-1)

print('Yes')
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()
  ma = H[i]
   
print('Yes')
n = int(input())
apple = list(map(int, input().split()))
cat = []
count = 0
for i in range(n - 1):
    if apple[i] <= apple[i + 1]:
        cat.append(apple[i])
    else:
        cat.append(apple[i] - 1)
cat.append(apple[-1] + 1)
for i in range(n - 1):
    if cat[i] <= cat[i + 1]:
        pass
    else:
        count = 1
        break    
print("Yes" if count == 0 else "No")
N=int(input())
H=list(map(int,input().split()))

F=True
G=False

for i in range(N-1):
    if H[i]<=H[i+1]:
        G=False
    else:
        if G:
            F=False
        elif H[i]==H[i+1]+1:
            G=True
        else:
            F=False

if F:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
for i in range(N-2):
    if H[i] - H[i+2] >= 2:
        ans = "No"
print(ans)
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    N = int(input())
    h = list(map(int, input().split()))
    for i in range(N-1):
        if abs(h[i] - h[i+1]) > 1 and i != N-2:
            ans = 'No'
            break
        elif h[i] > h[i+1]:
            h[i] -= 1
    print(ans)

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
    if (H[i-1] < H[i]):
        H[i] -= 1
print('Yes')
n = int(input())
li = list(map(int,input().split()))
ans = "Yes"

if n == 1:
    print(ans)
else:
    for i in range(n):
        if li[i] + 1 < max(li[:i+1]):
            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]): H[0] -= 1
for i in range(1, N - 1):
    if (H[i + 1] < H[i] and H[i] - 1 >= H[i - 1]):
        H[i] -= 1
for i in range(N - 1):
    if (H[i + 1] < H[i]):
        print('No')
        exit(0)
print('Yes')
import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
for i in range(n-1):
    dif = h[i] - h[i+1]
    if dif > 1:
        print(ans)
        sys.exit()
    elif dif == 1:
        h[i] -= 1

for i in range(n-1):
    dif = h[i] - h[i + 1]
    if dif > 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)
N=int(input())
L=list(map(int,input().split()))
M=[0]*N
count=0
for i in range (N-1):
	if L[i]>L[i+1]:
		L[i]-=1
		M[i]=1
	else:
		count+=1
if count==(N-1):
	print("Yes")
	exit()
count=0
for i in range (N-1):
	if L[i]>L[i+1]:
		if M[i]==1:
			print("No")
			exit()
		else:
			L[i]-=1
			M[i]=1
	else:
		count+=1
if count==(N-1):
	print("Yes")
	exit()
print("Yes")
# -*- coding: utf-8 -*-
n = int(input())
h = list(map(int, input().split()))

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

print('Yes' if cnt < 2 else 'No')
n = int(input())
h = list(map(int, input().split()))

zenkai_gen = False
no_flag = False

for i in range(n-1):
  sa = h[i+1] - h[i]
  
  if (zenkai_gen == True) and (sa < 0):
    no_flag = True
  elif sa < -1:
    no_flag = True
    
  if sa <= 0:
    zenkai_gen = True
  else:
    zenkai_gen = False

if no_flag:
  print("No")
else:
  print("Yes")
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 > 1:
    print('No')
else:
    print('Yes')
N = int(input())
H = list(map(int, input().split()))

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

for i in range(N-1):
  if H[i] <= H[i+1]:
    continue
  elif H[i] > H[i+1]:
    if H[i] - H[i+1] == 1:
      H[i] -= 1 
    elif H[i] - H[i+1] >= 2:
      print("No")
      exit(0)
      
for i in range(N-1):
  if H[i] > H[i+1]:
    print("No")
    exit(0)
    
print("Yes")
N=int(input())
*H,=map(int,input().split())

i=0
sm=[0]*(N-1)
while i+1<=N-1:
    sm[i]=min(H[i+1]-H[i],0)
    i+=1

print('YNeos'[sum(sm)<-1::2])
n = int(input())
h = list(map(int, input().split()))

h_new = []

for i in range(n-1):
    if h[i] - h[i+1] >=1:
        h_new.append(h[i]-1)
    else:
        h_new.append(h[i])
h_new.append(h[-1])

cnt = 0
for i in range(n-1):
    if h_new[i] < h_new[i+1]:
        print('No')
        exit()
    else:
        cnt += 1

if cnt == len(h_new)-1:
    print('Yes')
n = int(input())
s = list(map(int, input().strip().split(" ")))

flg = 0

for i in range(n-1):
    if s[i] - s[i+1] >= 2 or (s[i-1] ==  s[i] and s[i+1] - s[i] < 0):
        print("No")
        flg = 1
        break
    elif  s[i] - s[i+1] == 1:
        s[i] = s[i] - 1

if flg == 0:
    print("Yes")
N=int(input())
Hlist=list(map(int,input().split()))
flag=True
for i in range(N-1):
    if Hlist[i]>Hlist[i+1]:
        Hlist[i]-=1
for i in range(N-1):
    if Hlist[i]>Hlist[i+1]:
        flag=False
        break
print('Yes' if flag else 'No')
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 == sorted(h):
    print('Yes')
else:
    print('No')
N = int(input())
h = list(map(int, input().split()))
h.reverse()
f = [0] * N
ans = 'Yes'
for i in range(1, N):
    if h[i] - h[i -1] > 0 and f[i -1] == 0:
        h[i - 1] += 1
        f[i - 1] = 1

for i in range(1, N):
    if h[i] - h[i -1] > 0 and f[i -1] == 0:
        h[i - 1] += 1
        f[i - 1] = 11
    if h[i] - h[i -1] > 0:
        ans = 'No'

print(ans)
# C - Build Stairs

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

print(ans)
N=int(input())
S=list(map(int,input().split()))
Z=[0]*N

for i in range(1,N):
    Z[i]=S[i]-S[i-1]


flug=False
for i in range(N):
    
    if  Z[i]<=-2:
        print("No")
        exit()
        
    elif Z[i]==-1 and flug==False:
        flug=True
    elif Z[i]==-1 and flug==True:
        print("No")
        exit()
    else:
        flug=False
print("Yes")
import numpy as np
N = int(input())
H = np.array(list(map(int,input().split())))
D = np.diff(H,n=1)
if len(D[D <= -1]) <= 1:
    print('Yes')
else:
    print('No')
n = int(input())
h = list(map(int, input().split()))

last = h[-1]
p = 'Yes'
for i in h:
  if i > last + 1:
    p = 'No'
print(p)
n = int(input())
li = list(map(int,input().split()))
flag = True
ugokasenaiflag = False
for i,l in enumerate(li):
    if i == 0:
        continue
    if li[i-1] - l >1:
        flag = False
        break
    if li[i-1] - l == 1:
        if ugokasenaiflag:
            flag = False
            break
        else:
            ugokasenaiflag = True
    else:
        ugokasenaiflag = False
        
if flag:
    print('Yes')
else:
    print('No')
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if h[i] - 1 == h[i+1]:
        ans = 1
        h[i] -= 1
        if h[i-1] > h[i]:
            ans = 0
            break
    elif h[i] <= h[i+1]:
        ans = 1
    else:
        ans = 0
        break
if n ==  1:
    print('Yes')
elif ans == 1:
    print('Yes')
else:
    print('No')
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')
import sys
N=int(input())
A=list(map(int,input().split()))
mxA=A.index(max(A))
#if A[mxA::]

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


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

if h[0]-h[-1] == 0:
    print("No")
else:
    print("Yes")
N = int(input())
H = list(map(int, input().split()))

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

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

for i in range(h.index(max(h))+1,n):
    if max(h)-h[i]>=2:
        print('No')
        exit()
print('Yes')
n = int(input())
H = list(map(int, input().split()))
dif = list(map(lambda x: H[x + 1] - H[x], range(n - 1)))
count = 0
for d in dif:
    if d < 0:
        count += 1
    else:
        count = 0

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


print('Yes')
n = int(input())
li = list(map(int,input().split()))
ans = "Yes"

if n == 1:
    print(ans)
else:
    for i in range(n):
        if li[i] + 1 <= max(li[:i+1]):
            ans = "No"
            break

print(ans)