peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
h = list(map(int, input().split()))
if len(h) == 1:
  print("Yes")
elif h[0] >= h[1] + 2:
  print("No")
else:
  for i in range(n-2):
    if h[i] >= h[i+2] + 2:
      print("No")
      break
  else:
    print("Yes")
n = int(input())
h = list(map(int, input().split()))
ans = ''
for i in range(1, n -1):
  if i + 1 != n - 1:
    if -1 <= h[i] - h[i - 1] and -1 <= h[i + 1] - h[i]:
      next
    else:
      ans = 'No'
      break
  else:
    if h[i + 1] >= h[i] and -1 <= h[i] - h[i - 1]:
      next
    else:
      ans = 'No'
      break
if ans == '':
  ans = 'Yes'
print(ans)
N = int(input())
h = list(map(int,input().split()))

if N == 1:
  pass
elif N==2:
  if h[0] <= h[1]:
    pass
  else:
    print('No')
    exit()
elif N >= 3:
  for i in range(N-2):
    if (h[i+1] > h[i+2]) and (h[i]-1 >= h[i+1]) :
      print('No')
      exit()
    elif h[i] >= h[i+1]+2:
      print('No')
      exit()
print('Yes')
n = int(input())
h = list( map(int,input().split()) )

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

    if m == -1:
      m = h[i-1]
    else:
      if h[i-1] < m:
        break

    if h[i] < h[i-1]:
      break
else:
  ck = True

print('Yes' if ck else 'No')
n=int(input())
h=list(map(int,input().split()))
ans='Yes'
h_max=h[0]
for i in range(1,n):
  if h_max+1>h[i]:
    break
#    print(h_max,h[i],ans)
  elif h_max+1==h[i]:
    h_max=h[i]
#    print(h_max,h[i],ans)
  else:
    ans='No'
#    print(ans)
print(ans)
N = int(input())
H = list(map(int,input().split()))
if N == 1:
    print('Yes')
    exit()
if N == 2:
    if H[0] - H[1] > 1:
        print('No')
        exit()
    else:
        print('Yes')
        exit()
for i in range(1,N-1):
    if H[i-1] < H[i] and H[i] > H[i+1]:
        H[i] -= 1
for i in range(1,N):
    if H[i-1] > H[i]:
        print('No')
        exit()
print('Yes')
def main(n: int, h: list):
    _max = h[0]

    for h in h:
        if _max == h:
            continue

        if (h - _max) == 1:
            _max = h
        elif (h - _max) >= 2:
            print("No")
            return

    print("Yes")


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

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

can = True

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

print("Yes" if can else "No")
# 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>2 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()))

ht=[h[0],h[0]]

ans="Yes"
for i in h:
  if i in ht:
    pass
  elif i - ht[0] == 1:
    ht[1] = ht[0]
    ht[0] = i
  elif i - ht[0] == 2:
    ht[0] = ht[1] = i
  else:
    ans="No"
    break
    
print(ans)
n = int(input())
h = list(map(int, input().split()))

h_new = []
h_new.append(h[0]-1)

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

print(h_new)
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 = 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"
      break
    elif num[i] > num[i + 1]:
      jadge = "false"
      break
    else:
      jadge = "true"
  else:
    continue

if jadge == "true":
  print("Yes")
else:
  print("No")
n = int(input())
h = list(map(int, input().split()))
mx = 0
for i in range(n):
    if h[i] - mx > 1:
        print('No')
        exit()
    mx = max(mx, 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]+1:
        H[i]-=1
        if H[i]<H[i-1] and i!=0:
            print('No')
            exit()
    elif H[i]-H[i+1]>=2:
        print('No')
        exit()
print('Yes')
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
c=0
for i in range(1,n):
    if h[i-1]-h[i]==1:
        if c==0:
            h[i-1]=h[i-1]-1
            c=1
            continue
        elif c==1:
            ans="No"
            break
    if h[i-1]-h[i]>1:
        ans="No"
        break
print(ans)
N = int(input())
H = [int(x) for x in input().split()]

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

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

ans = 'Yes' if flg else 'No'
print(ans)
n = int(input())
h = [1]
h += list(map(int, input().split()))
hm = list(map(lambda x: x - 1, h))
x = []
for i in range(1, n + 1):
    if h[i] > h[i - 1]:
        x.append(hm[i])
    else:
        x.append(h[i])

print("Yes") if max(x) == x[-1] else print("No")
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

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

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

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(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")
n = int(input())
h = list(map(int, input().split()))

last = h[-1]
p = 'Yes'
t = h[0]
for i in h:
  if i > last + 1 or t > i:
    p = 'No'
  t = i
print(p)
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(i,ans)
print("Yes" if ans==1 else "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:
        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())
H = list(map(int,input().split()))
flag = 0
for i in range(N - 1):
  if H[i] > H[i+1] + 1 or H[i]+2 <= H[i+1]:
    flag += 1
if flag == 0:
  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
    if k < 1 and (A[i] - A[N-1]) <=1:
        print("Yes")
    else:
        print("No")
N = int(input())

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

H = 0
ck = 0

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

for i in range(n-1):
    if H[i]<H[i+1]+1:
        ans='Yes'
    if H[i]==H[i+1]+1:
        H[i]-=1
        ans='Yes'
    if H[i]>H[i+1]+1:
        ans='No'
        break
        
print(ans)
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
    if a[i] - a[i-1] > 1:
        print('No')
        break
else:
    print('Yes')
n=int(input())
s=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if not s[i]-1<=s[i+1]:
    print("No")
    exit()
print("Yes")
n = int(input())
h = [int(e) for e in input().split()]
flg = "Yes"
for i in range(n-1):
    h[i] -= 1
    if h[i+1] <= h[i]:
        flg = "No"
        break
print(flg)
N = int(input())
boxes = list(map(int,input().split()))
max_num = 0
prev = 0
for box in boxes:
    if not (box - prev >= 0):
        if not (box - prev == -1 and prev-1 >= max_num):
            print("No")
            exit()
    if prev - max_num > 0:
        max_num = prev
    prev = box
print("Yes")
n=int(input())
list=list(map(int,input().split()))
if list[0]==min(list) and (list[0]<list[n-1] or n==1):
    print("Yes")
else:
    print("No")
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]-1)
  else:
    print("Yes")
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:
        H[i] -= 1
        if i == 0:
            continue
        if H[i-1] > H[i]:
            flg = 0
            break
if flg == 1:
    print('Yes')
else:
    print('No')
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]
for i in range(n-1):
    if h[i] == h[i+1]:
        pass
    elif h[i] == h[i+1] +1:
        pass
    elif h[i] == h[i+1] +2:
        h[i+1] += 1
    elif h[i] == h[i+1] -1:
        h[i + 1] -= 1
    else:
        print("No")
        exit()
print("Yes")
N=int(input())
H=list(map(int,input().split()))
a=0
for i in range(N-1):
    a=max(H[:i+1])
    if H[i]<a-1:
        print("No")
        break
else:
    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()
hpre = h[-1]
print(h[:-1][::-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")
n = int(input())
A = list(map(int,input().split()))
for i in range(n-1):
  if A[i+1]-A[i] >= -1:
    if A[i+1] >= A[i]:
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]
for i in range(n-1):
    if h[i] == h[i+1]:
        pass
    elif h[i] == h[i+1] +1:
        pass
    elif h[i] == h[i+1] +2:
        h[i+1] += 1
    else:
        print("No")
        exit()
print("Yes")
import numpy as np
n = int(input())
h = np.array([int(i) for i in input().split()])
diff = np.diff(h)
flag = True
current = -1
for i, j in enumerate(diff):
    if j < -1:
        flag = False
        break
    elif j > 0:
        flag = True
        current = -1
    elif j == -1:
        if not flag:
            break
        flag = False
        current = i
    else:
        flag = True
        current = i
    if current == len(diff) - 1 and not flag:
        flag = True
print('Yes') if flag 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 and h[i+2]-h[i+1]<-1:
        f=0
        break
    if h[i+1]-h[i]<-1 or h[i+2]-h[i+1]<-1:
        f=0
        break
    if h[i+1]-h[i]==-1 and h[i+2]-h[i+1]==-1:
        f=0
        break
       
if f:
    print("Yes")
else:
    print("No")
n=int(input())
l=list(map(int,input().split()))
if n!=1:
  m=l[0]
  cnt=0
  for i in range(n):
    if l[i]<m:
      m=min(m,l[i])
      cnt+=1
    if cnt==2:
      print('No')
      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]+1:
        H[i]-=1
    if H[i]>H[i+1]+1:
        ans='No'
        break
        
print(ans)
N = int(input())
H = list(map(int, input().split()))
yesno = 'Yes'
p=0
for i in range(N-1):
    if H[i] <= H[i+1]:
        p=0
    elif H[i] - 1 == H[i+1]:
        p += 1
        if p == 2 :
            yesno = 'No'
            break
    else:
        yesno = 'No'
        break
print(yesno)
n = int(input())
h = [int(i) for i in input().split()]
for i in range(n - 1):
     if h[i] > h[i+1]:
        if h[i] == h[i+1] + 1:
             h[i] -= 1
        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 i in 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 = list(map(int, input().split()))

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

if H == 2 and H[0] <= H[1]:
  print('Yes')
  exit()
elif H == 2 and H[0] > H[1]:
  print('No')
  exit()

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

print('Yes')
import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
h[0] -= 1
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

max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif < 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)
n = int(input())
H = list(map(int,input().split()))

ans = "Yes"
c=0
for i in range(n-1):
    if H[i]-1>H[i+1] :
        ans = "No"
        break
    elif H[i]>H[i+1] :
        c+=1
        if c>=2 :
            ans = "No"
            break
print(ans)
n=int(input())
s=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if s[i]-1>s[i+1]:
    print("No")
    exit()
print("Yes")
#python3
n=int(input())
h=[int(i) for i in input().split()]

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

if ok:
  print('Yes')
else:
  print('No')
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:
      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')
from sys import stdin

n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]

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

print("Yes" if h == sorted(h, key=int) else "No")
N = int(input())
H = map(int,input().split())
min = 0
m = 0
ans = 'Yes'
for i in H:
  if m == 0:
    m = i
    continue
  if m <= i + 1:
    m = max(m,i - 1)
  else:
    ans = "No"
    break
print(ans)
N = int(input())
H = [int(x) for x in input().split()]

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

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

ans = 'Yes' if flg else 'No'
print(ans)
n=int(input())
h=list(map(int,input().split()))
maxm=h[0]
for i in range(1,n):
    if maxm<h[i]: print('No'); exit()
    maxm=max(maxm,max(0,h[i]-1))
print('Yes')
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

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

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

a = sorted(h)

if h == a:
    print("Yes")
else:
    print("No")
def solve():
    ans = "Yes"
    for i in range(N-2):
        if H[i] - H[i+2] > 1 or H[i] - H[i+1] > 1:
            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()))

# if max(h) - h[n - 1] > 1:
#     print('No')
#     exit(0)
if n == 1:
    print('Yes')
    exit(0)
else:
    for i in range(n - 1 , 0):
        if max(h[i - 1] - 1, 1) > h[i]:
            print('No')
            exit(0)
        else:
            h[i - 1] = max(h[i - 1] - 1, 1)

print('Yes')
import sys

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

while tmp <= N-2:
  if H[tmp] > H[tmp+1]:
    cnt += 1
  if cnt >= 2:
    print("No")
    sys.exit()
  tmp += 1
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()))
h[0]=h[0]-1
for i in range(1,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")
#!/usr/bin/env python3

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

h.reverse()


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

print("Yes")
x=int(input())
s=list(map(int,input().split()))
s[0]=max(0,s[0]-1)
for n in range(1,x):
    if s[n]<s[n-1]:
        print('No')
        exit(0)
    s[n]-=1

print('Yes')
N=int(input())
H=list(map(int, input().split()))
no = False
for i in range(N-1):
  if H[i]>H[i+1]+1:
    no = True
    break
  elif H[i]==H[i+1]+1:
    H[i] -= 1
#print(H)
print(['Yes','No'][no])
n = int(input())
x = list(map(int,input().split()))
y = []
for i in range(n-1):
  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())
high = list(map(int,input().split()))

for x in range(n-1):
  if high[x] - high[x+1] >= 2:
    print("No")
    break
  elif high[x] - high[x+1] == 1:
    high[x] = high[x] - 1
    
else:
  new_high = list(sorted(high))
  if new_high == high:
    print("Yes")
    
  else:
    print("No")
n = int(input())
h = list(map(int, input().split()))

ht = h[0]
ans="Yes"
for i in h[:-1]:
  if i - ht == 0:
    ht = i
  elif i - ht == 1:
    ht = i-1
  else:
    ans="No"
    break
    
print(ans)
n = int(input())
h = list(map(int, input().split()))


h[0] -= 1
for i in range(0, n-1):
    if h[i] > h[i+1]:
        print('No')
        break
    h[i+1] -= 1
else:
    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]: #単調非減少になっていないとき、手前の要素の値を1減らす
   arr[i-1]-=1
   if arr[i]>arr[i-1]: #1減らしても単調非減少にならないとき、答えはNo
     print('No')
     break
else:
 print('Yes')
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
for i in range(N - 1):
  f = 1
  if a[i + 1] - a[i] < 0:
    a[i] -= 1
    f = 0
  if a[i] - a[i + 1] < 0:
    a[i + 1] -= 1
    f = 0
  if f: a[i] -= 1
for i in range(N - 1):
  if a[i + 1] < a[i]:
    print("No")
    exit(0)
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] - s[i+1] >= 1):
        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())
h = [int(x) for x in input().split()]
ans = 'Yes'
for i in range(1, n):
    if h[i-1] == h[i]:
        pass
    elif h[i-1] > h[i]-1:
        ans = 'No'
        break
    elif h[i-1] == h[i]-1:
        h[i] -= 1
print(ans)
N=int(input())
H=list(map(int, input().split()))
ans = "Yes"
for i in range(N-1)[::-1]:
	if H[i+1]<H[i]:
		H[i]-=1
		if H[i]<H[i-1]:
			ans="No"
			break
print(ans)
N = int(input())
H = [int(x) for x in input().split()]

flg = True
for i in range(2, N):
    if H[i-1] - H[i] == 1:
        if H[i-2] == H[i-1]:
            flg = False
            break
        else:
            H[i-1] -= 1
ans = 'Yes' if flg else 'No'
print(ans)
def do():
    k=0
    a=int(input())
    l=list(map(int,input().split()))
    for i in range (a-1):
        if l[i]-l[i+1]>=2:
            return "No"
        elif l[i]-l[i+1]==1:
            k+=1
        else:
            k=0
    if k>=2:
        return "No"
    else:
        return "Yes"

print(do())
a = int(input())
b = list(map(int,input().split()))
c = b[0]
d = 0
e = 0
for i in range(a-1):
  if c - 1 <= b[i+1]:
    c =  b[i+1]
    d += 1
for i in range(a-2):
  if b[i+2] - b[i] >= 2:
    e += 1
if d == a-1 and e == a-2:
  print("Yes")
else:
  print("No")
N = int(input())
H = list(map(int, input().split()))
bl = True

for i in range(N-1):
    if H[i] - H[i+1] == 1:
        if i < N-2 and H[i+1] - H[i+2] > 0:
            bl = False
    elif H[i] - H[i+1] > 1:
        bl = False

print('Yes' if bl else 'No')
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in range(n-1):
        if h[i] - h[i+1] > 1:
            print('No')
            return 0
    print('Yes')

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

F = ['T']*N
suc = True
for i in range(0,N-1):
    if int(H[i]) > int(H[i+1]):
        if int(H[i]) - int(H[i+1]) <= 1:
            if F[i] == 'T':
                F[i+1] = 'S'
            else:
                suc = False
                break
        else:
            suc = False
            break

if suc:
    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] < 0:
		h[i] -= 1
for i in range(n-1):
	if h[i+1]-h[i] < 0:
		print ("No")
		exit()
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]
  else:
    if h[i]>=Fx:
      FL=False
print(ans)
n = int(input())
h = list(map(int, input().split()))

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

print('Yes')
n = int(input())
h = list(map(int,input().split()))
flag = False
min = 0 
for i in range(n-2):
    min = h[i]
    if h[i+1] < min -1:
        flag = True
        break
    elif h[i+1] == min -1 and h[i+2] <= min-2:
        flag = True
        break
    else:
        pass

if n ==2 :
    if h[0] > h[1] +1:
        flag = True

if flag:
    print('No')
else:
    print('Yes')
N = int(input())
H = [int(x) for x in input().split()]
H2 = H.copy()
flg=True

for i in range(N-1):
    if H[i] - H[i+1] == 1:
        H[i] -= 1
        H2[i+1] -= 1
        break
        
for i in range(N-1):
    if (H[i] - H[i+1] == 1) or (H2[i] - H2[i+1] == 1):
        flg=False
        break

ans='Yes' if flg else 'No'
print(ans)
n = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(n - 1):
    if i <= n - 3:
        if H[i] - H[i + 1] >= 2 or H[i] > H[i + 1] > H[i + 2]:
            flag = False
    else:
        if H[i] - H[i + 1] >= 2:
            flag = False

print('Yes' if flag == True else 'No')
a = int(input())
num_list = list(map(int,input().split()))
flag = ""
for i in range(a-1):
  if num_list[i]-1 <= num_list[i+1]:
    flag = "ok"
  else:
    flag = "ng"
if flag == "ok":
  print("Yes")
else:
  print("No")
n = int(input())
h = list(map(int,input().split()))
if n == 1:
    print('Yes')
for i in range(n-1):
    if h[i]>h[i+1]+1:
        print('No')
        break
    if i > 0:
        if (h[i]-1==h[i-1]) or (h[i]==h[i-1]-1):
            if h[i]==h[i+1]+1:
                print('No')
                break
    if i == n-2:
        print('Yes')
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:
        H[i]=H[i]-1
    else:
        H[i]=H[i]
for n in range(0,N-1):
    if H[n]<=H[n+1]:
        num=num+1
if num==N-1:
    print("Yes")
else:
    print("No")
n = int(input())
h = list(map(int,input().split()))
num = h[0]
for i in range(n-1):
    if h[i+1] < h[i]:
        h[i] -= 1
for i in range(n-1):
    if h[i+1] < h[i]:
        print("No")
        break
else:
    print("Yes")