peterverebics/CodeNet_Python_118 huggingface dataset:
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')
    exit()
print('Yes')
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(1, N):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1

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

now = 0
for i in h:
    if now < i:
        now = i - 1
    elif now == i:
        pass
    else:
        print('No')
        break
else:
    print('Yes')
N = int(input())
H = list(map(int, input().split()))

flg = True
for i in range(N-2, 0, -1):
    if H[i] - 1 > H[i+1]:
        flg = False
        break
    else:
        if H[i] > H[i+1]: H[i] -= 1
if flg:
    print('Yes')
else:
    print('No')
import sys

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

def main():
  for i in reversed(range(n-1)):
    if h[i] - h[i+1] > 1:
      return False
      exit()
    elif h[i] - h[i+1] == 1:
      h[i] -= 1
    else:
      continue
  return True

if main() == True:
  print('Yes')
  sys.exit()

h[n-1] -= 1

if main() == True:
  print('Yes')

else:
  print('No')
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n):
    if h[i]-h[i-1] < 0:
        print('No')
        exit()
    if h[i] - h[i-1] > 0:
        h[i] -= 1
print('Yes')
# coding: utf-8
# Your code here!
import sys

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

n = int(input())
li = list(map(int, input().split(" ")))

for i in range(n - 1, 0, -1):
    if li[i - 1] <= li[i]:
        continue
    li[i - 1] -= 1
    if li[i - 1] > li[i]:
        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+1] - h[i] == 1:
        h[i+1] = h[i+1] - 1
    elif h[i+1] - h[i] > 1:
        print("No")
        exit()
else:
    print("Yes")
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1] - 1
        if not h[i-1] <= h[i]:
            print('No')
            return
        else:
            continue
    print('Yes')

if __name__ == '__main__':
    main()
N=int(input())
W=list(map(int,input().split()))
for i in range(N-1,0,-1):
  if W[i-1]>W[i]+1:
    print("No")
    exit()
  elif W[i-1]==W[i]+1:
    W[i-1]-=1
print("Yes")
n = int(input())
h = list(map(int, input().split()))
flag = True
for i in range(n-1):
    if h[i] > h[i+1] + 1:
        flag = False
        break
    elif h[i] == h[i+1] + 1:
        h[i+1] += 1
if flag:
    print("Yes")
else:
    print("No")
N = int(input())
a = list(map(int, input().split()))

if N == 1:
  print("Yes")
  
else:
  flag = True
  for i in range(N-1):
    if a[len(a)-1-i]-a[len(a)-2-i] < -1:
      flag=False
      break
    if a[len(a)-1-i]-a[len(a)-2-i] == -1:
      a[len(a)-2-i]-=1

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

s=0
flag = True

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

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

h = H[0]

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

def main():
    N = int(sys.stdin.readline().rstrip())
    H = list(map(int, input().split()))


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

        elif  H[x] == H[x-1] - 1:
            H[x-1] -= 1

        else:
            print('No')
            sys.exit()

    print('Yes')


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

max=0
cnt=0
for i in range(N):
    if max-H[i]>=2:
        print('No')
        break
    else:
        cnt+=1
        if H[i]>max:
            max=H[i]
if cnt==N:
    print('Yes')
import math
import os
import random
import re
import sys

def check_non_decreasing_squares(n: int, a: list):
    for i in range(1, n):
        if a[i] != a[i - 1]:
            if a[i] - 1 < a[i - 1]:
                print("No")
                sys.exit(0)
            a[i] -= 1
    print("Yes")

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().rstrip().split()))
    check_non_decreasing_squares(n, a)
from collections import deque

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

ato = H.pop()

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

for i in range(N-1, 0, -1):
    mae = H.pop()
    if ato - mae < -1:
        print('No')
        exit()
    elif ato - mae == -1:
        ato = mae - 1
    else:
        ato = mae

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]-=1
  if h[i]>h[i+1]:
    ans="No"
    break
  
print(ans)
n=int(input())
a=list(map(int,input().split()))
ans='Yes'
a[0]-=1
for i in range(n-1):
  if a[i]>a[i+1]:
    ans='No'
  elif a[i+1]>a[i]:
    a[i+1]-=1
print(ans)
n = int(input())
h = list(map(int,input().split()))
check = True
for i in range(1,n):
    if h[i] >= h[i-1]:
        continue
    elif h[i] + 1 == h[i-1]:
        h[i] += 1
    else:
        check = False
        break
print("Yes" if check else "No")
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    k = True
    for i in range(1, N):
        if H[i] >= H[i-1]:
            if H[i] - 1 >= H[i - 1]:
                H[i] = H[i] - 1
        else:
            k = False
            break
    if k:
        print("Yes")
    else:
        print("No")


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

Max=0
i=0
while i<N:
    
    if List[i]-Max <= -2:
        print("No")
        quit()
    Max=max(Max,List[i])
    
    i+=1

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

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

print('Yes')
N = int(input())
A = [0]+list(map(int, input().split()))

l = -1
ans = "Yes"
for i in range(1, N+1):
    if A[i] > A[i-1]:
        A[i] -= 1
    elif A[i] == A[i-1]:
        continue
    else:
        ans = "No"
print(ans)
N = int(input())
H = [int(x) for x in input().split()]

MAX = 0
Flag = True
for T in range(0,N):
    if H[T]>MAX:
        MAX = H[T]
    if MAX-H[T]>=2:
        Flag = False
        break
if Flag:
    print('Yes')
else:
    print('No')
def main():
    n=int(input())
    H=list(map(int,input().split()))
    now=H[0]-1
    if n==0:
        print('Yes')
        return
    for h in H[1:]:
        if now > h:
            print('No')
            return
        elif now == h:
            now = h
        else:
            now = h -1
    print('Yes')
main()
n=int(input())
h=list(map(int,input().split()))
k=h[0]-1
for i in range(1,n-1):
    if k<=h[i]-1:k=h[i]-1
    if k>h[i+1]:
        print('No')
        exit()
print('Yes')
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
H = inintl()

h = H[0]

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

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

for i in range(n):
    if h[i] < num-1:
        print("No")
        exit(0)
    num = max(num, h[i])

print("Yes")
n = int(input())
H = list(map(int, input().split()))
H[0] -= 1
ans = 0

for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    if H[i] > H[i+1]:
        ans = 1
        break

if ans == 0:
    print('Yes')
else:
    print("No")
n = int(input())
h = list(map(int, input().split()))
# sv = h[n-1]
ok = True
for i in range(n-1)[::-1]:
    # if h[i] - sv + 1 >= 2:
        # ok = False
    if h[i] <= h[i+1]:
        continue
    elif h[i] == h[i+1] + 1:
        h[i] -= 1
    else:
        ok = False
    # if h[i] - h[i-1] < 0:
        # ok = False
if ok:
    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] = H[i+1]-1
    if H[i] > H[i+1]:
        ans = "No"
        break

print(ans)
n = int(input())
H = list(map(int,input().split()))
H[0] -= 1
ans = "Yes"
for i in range(1,n):
    if H[i] < H[i-1]:
        ans = "No"
        break
    if H[i]-1 >= H[i-1]:
        H[i]-=1
print(ans)
def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    highest = h_list[0]
    is_able = True

    for h in h_list:
        if highest > h:
            is_able = False
            break

        if highest + 1 < h:
            highest = h - 1

    if is_able:
        print("Yes")
    else:
        print("No")


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

seed = h[0]
checker = True

for i in range(1,n):
    if h[i] == h[i-1]:
        continue
    d = h[i] - h[i-1] + 1
    if d > 0:
        checker = True
        pass
    elif d == 0:
        if checker:
            checker = False
        else:
            print('No')
            quit()
    else:
        print('No')
        quit()


print('Yes')
import sys
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
     elif h[i] <= h[i-1] - 2:
          print('No')
          sys.exit()
print('Yes')
N = int(input())
lis = list(map(int, input().split()))

for i in range(N-1):
    if lis[i] < lis[i+1]:
        lis[i+1] -= 1
    elif lis[i] == lis[i+1]:
        continue
    else:
        print("No")
        exit()

print("Yes")
n = int(input())
h = list(map(int, input().split()))
ans ='Yes'
mah = 0
for i in h:
    mah = max(i, mah)
    if i < mah - 1:
        ans = 'No'
        break
print(ans)
n = int(input())
a = list(map(int,input().split()))
m = a[0]
for i in range(1,n):
    if m>a[i]+1:
        print("No")
        break
    m = max(m,a[i])
else:
    print("Yes")
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
H = LI()
for i in range(N):
    if i==0:
        H[i] -= 1
        continue
    if i==N-1:
        if H[i-1]<=H[i]:
            continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')
n = int(input())
H = 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+1]:
    print('No')
    break
else:
  print('Yes')
n=int(input())
l=list(map(int, input().split()))
st=l[n-1]
for _ in reversed(l):
  if _-1>st:
    print("No")
    exit()
  elif _-1==st:
    st==_-1
  else:
    st=_
print("Yes")
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(N-1,0,-1):
    if H[i] < H[i-1]:
        H[i-1] -= 1
    if H[i] < H[i-1]:
        print('No')
        exit()
print('Yes')
import sys

input = sys.stdin.readline
_ = int(input())
nums = map(int, input().split())
maxnum = 0

for x in nums:
    if maxnum < x:
        maxnum = x
    if maxnum - x > 1:
        print('No')
        sys.exit() 

print('Yes')
import sys
n=int(input())
h=[int(x) for x in input().split()][::-1]

for i in range(n-1):
    if h[i]>=h[i+1]:
        continue
    elif h[i]==h[i+1]-1:
        h[i+1]-=1
    else:
        print("No")
        sys.exit()
print("Yes")
n=int(input())

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

for i in range(n-1, 0, -1):
    #print(t)
    if t[i] < t[i-1]-1:
        print('No')
        exit()
    elif t[i] == t[i-1]-1:
        t[i-1] -= 1
print('Yes')
N = int(input())

List = [int(i) for i in input().split(" ")[::-1]]

Min = List[0]
i=1
flag = 0

for i in range(N):
    if (List[i]-Min)>=2:
        flag=1
        break
    else:
        if List[i]<Min:
            Min=List[i]
if flag==0:
    print("Yes")
else:
    print("No")
N = int(input())
H = list(map(int,input().split()))
f = True
for i in reversed(range(1,N)):
    if H[i-1]<=H[i]:
        continue
    elif H[i-1]-H[i] == 1:
        H[i-1] -= 1
    else:
        f = False
        break

if f:
    print('Yes')
else:
    print('No')
# 136 C
import numpy as np
N = int(input())
H = list(map(int, input().split()))
H = np.array(H)

ans = 'Yes'
for i in range(N-2, -1, -1):
    if (H[i] - H[i+1])>0:
        if (H[i] - H[i+1])==1:
            H[i] += -1
        else:
            ans='No'
            break
print(str(ans))
n = int(input())
H = list(map(lambda x: int(x)-1, input().split()))
for i in range(n-1):
    if H[i] > H[i+1]:
        if H[i] <= H[i+1] + 1:
            # 次に1を足して大きいならOK
            # 足した場合は記録する
            H[i+1] += 1
        else:
            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:
        continue
    elif temp < i:
        temp = i-1
        continue
    else:
        print('No')
        exit()
else:
    print('Yes')
def main():
  _, *h=map(int, open(0).read().split())
  x=h[-1]
  for y in h[-2::-1]:
    if x<y-1:
      return 'No'
    x=y-(x<y)    
  return 'Yes'

if __name__ == '__main__':
  print(main())
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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


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

ans = 'Yes'
for i in range(1, n)[::-1]:
    if h[i] - h[i-1] == -1:
        h[i-1] -= 1
    elif h[i] - h[i-1] < -1:
        ans = 'No'

print(ans)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a[0] -= 1
for i in range(1,n):
    if a[i] > a[i-1]:
        a[i] -= 1
    elif a[i] < a[i-1]:
        print('No')
        break
else:
    print('Yes')
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

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

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

ans = "Yes"
m = h[0]

for i in range(1, n):
    m = max(m, h[i])
    if h[i] < m - 1:
        ans = "No"

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] -1:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        break
else:
    print('Yes')
n = int(input())
h = list(map(int,input().split()))
prev = 10**9+1
stair = "Yes"
hlen = len(h)
for i in range(n):
  hgt = h[hlen-1-i]
  if hgt>prev+1:
    stair = "No"
    break
  elif hgt==prev+1:
    prev = hgt-1
  else:
    prev = hgt
print(stair)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
H = iil()
mh = 0
for i in H:
    if mh - 1 > i:
        print('No')
        exit()
    else:
        mh = max(mh,i)
print('Yes')
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))

m = 0
flag = True

for i in h:
  if m > i + 1:
    flag = False
    break

  if i > m:
    m = i

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

a = h[0]
for i in range(1,n):
    if a == h[i]:
        pass
    elif a < h[i]:
        h[i] -= 1
        a = h[i]
    else:
        print("No")
        exit()
print("Yes")
N = int(input())

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

c = 1
a = "Yes"

for i in range(N):
  if H[i] > c:
    c = H[i]-1
  elif H[i] < c:
    a = "No"
    break
print(a)
N = int(input())
H = list(map(int, input().split()))

No = 0

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

print("Yes" if No == 0 else "No")
n = int(input())
h = list(map(int,input().split()))
h = [0]+h+[10**9+1]
for i in range(1,n+1):
  if h[i] > h[i+1]+1:
    print("No")
    exit()
  elif h[i] == h[i+1]+1:
    h[i] -= 1
    if h[i-1] > h[i]:
      print("No")
      exit()
  else:
    if h[i-1]  < h[i]:
      h[i] -= 1
print("Yes")
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = True
    m = 0
    for i in range(N-1):
        m = max(m, A[i])
        if m-1 > A[i+1]:
            ans = False
    return 'Yes' if ans else 'No'

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

ans = "Yes"

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

max_h=0
ans='Yes'

for n in range(N):
    if H[n] > max_h:
        max_h = H[n]
        
    if H[n] < max_h-1:
        ans='No'
        
print(ans)
N = int(input())
H = [int(i) for i in input().split()]

is_true = True
before_tmp = 1
for i in range(N - 1):
    # 差分を計算
    tmp = H[i + 1] - H[i]
    if tmp < 0 and (tmp <= -2 or before_tmp <= -1):
        is_true = False
        break
    # 0の場合は飛ばす
    if tmp != 0:
        before_tmp = tmp

if is_true:
    print('Yes')

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

def f():
    global h
    for i in range(n - 1, 0, -1):
        diff = h[i - 1] - h[i]
        
        if diff >= 2:
            return 'No'
        elif diff == 1:
            h[i - 1] = h[i - 1] - 1
    
    return 'Yes'

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

def main():
  for i in reversed(range(n-1)):
    if h[i] - h[i+1] > 1:
      return False
      exit()
    elif h[i] - h[i+1] == 1:
      h[i] -= 1
    else:
      continue
  return True

if main() == True:
  print('Yes')

else:
  print('No')
#!/usr/bin/env python3

def main():
    N = int(input())
    *H, = map(int, input().split())

    h_min = H[0]
    flag = True
    for i in range(0, N):
        if H[i] - 1 >= h_min:
            H[i] = H[i] - 1
        elif H[i] < h_min:
            flag = False
            break
        h_min = H[i]
    
    if flag:
        print('Yes')
    else:
        print('No')


main()
n=int(input())
a=[int(x) for x in input().split()]

for i in range(n-1):
    if a[i]<a[i+1]:
        a[i+1]-=1
    if a[i]>a[i+1]:
        print("No")
        exit()
print("Yes")
n=int(input())
li=list(map(int,input().split()))
li[0]-=1
for i in range(1,n-1):
    if li[i]>=li[i+1] and li[i]>li[i-1]:
        li[i]-=1
li2=sorted(li)
if li==li2:
    print("Yes")
else:
    print("No")
N=int(input())
A=list(map(int,input().split()))
max_A=0
for i in range(N):
    if max_A<A[i]:
        max_A=A[i]
    if A[i]<max_A-1:
        print("No")
        exit()
print("Yes")
n = int(input())
hlst = list(map(int, input().split()))
bef = 0
for h in hlst:
  if h < bef:
    print("No")
    break
  elif h == bef:
    bef = h
  else:
    bef = h - 1
else:
  print("Yes")
N = int(input())
H = list(map(int,input().split()))
D = 0

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

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

tmp = Hs[0]
for h in Hs:
    if tmp - h > 1:
        print("No")
        exit()
    if h > tmp:
        tmp = h
print("Yes")
import sys
n = int(input())
l = list(map(int,input().split()))
maxs=l[0]
for i in range(1,n):
    if l[i]<maxs-1:
        print("No")
        sys.exit()
    elif l[i]>=maxs:
        maxs=l[i]
    
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()