Problem:
 Score : 300 points    Problem Statement There are N squares arranged in a row from left to right. The height of the i -th square from the left is H_i .  For each square, you will perform either of the following operations once:   Decrease the height of the square by 1 .  Do nothing.   Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.      Constraints  All values in input are integers.  1 \leq N \leq 10^5  1 \leq H_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  H_1  H_2  ...  H_N       Output If it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right, print Yes ; otherwise, print No .        Sample Input 1 5
1 2 1 1 3      Sample Output 1 Yes  You can achieve the objective by decreasing the height of only the second square from the left by 1 .       Sample Input 2 4
1 3 2 1      Sample Output 2 No       Sample Input 3 5
1 2 3 4 5      Sample Output 3 Yes       Sample Input 4 1
1000000000      Sample Output 4 Yes

Solution (Python):
n=int(input())
h=[int(x) for x in input().split()]
a=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")
      a=0
      break
if a==1:
  print("Yes")

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
Flag = "Yes"
maxh = 0

if n >= 2 :
  for i in range(1,n):
    if h[i-1] > h[i]:
      h[i-1] = h[i-1] - 1
      if h[i-1] > maxh:
        maxh = h[i-1] 
      if h[i-1] > h[i] or maxh > h[i] :
        Flag = "No"
      
print(Flag)

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

cmax = h[0]
ok = True
for i in h:
    cmax=max(cmax,i)
    if cmax-i>1:
        ok = False
        break
        
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
p,a=True,0
for h in H:
  if h>a:
    a=h-1
  elif a>h:
    p=False
    break
print("Yes" if p else "No")

Solution (Python):
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')

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
tmp = h[0]
isOK = True
for i in range(1,n):
    
    if tmp < h[i]:
        tmp = h[i] - 1
    elif tmp == h[i]:
        tmp = h[i]
    else:
        isOK = False
        break
if isOK:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    H=LI()
    
    now=0
    
    for i in range(N):
        if H[i]!=now:
            H[i]-=1
        now=H[i]
    
    flag=1
    now=0
    for i in range(N):
        if H[i]<now:
            flag=0
            break
        now=H[i]
        
    if flag:
        print("Yes")
    else:
        print("No")
            

main()

Solution (Python):
import numpy as np

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

max_ = 0
for h in H:
    max_ = max(max_,h)
    if h <= max_-2:
        print('No')
        exit()
else:
    print('Yes')

Solution (Python):

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

target = H[0]
target_max = 0
result = 'Yes'
for i in range(1,N):
    if (H[i] < target - 1) or (target_max > H[i]):
        result = 'No'
        break
    elif H[i] == target - 1:
        target -= 1
    else:
        target = H[i] - 1
    target_max = max(target,target_max)           
print(result)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
if(n==1):
    print("Yes")
else:
    f=0
    for i in range(n-1,-1,-1):
        if(l[i]+1==l[i-1]):
            l[i-1]-=1
    for i in range(n-1):
        if(l[i+1]<l[i]):
            f=1
            break

    if(f==0):
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
List = list(map(int, input().split()))
flg = True
if N ==1: print("Yes")
else:
  for i in range(1,N):
    if List[i]==List[i-1]:
      pass
    elif List[i]>List[i-1] or List[i]-1>=List[i-1]:
      List[i] = List[i]-1
    else:
      flg=False
      break
  if flg:
    print("Yes")
  else:
    print("No")

Solution (Python):


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

Solution (Python):
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')

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
H.reverse()

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

Solution (Python):
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')

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

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

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

    if H[i] >= H[i-1]:
        pass
    elif H[i] + 1 == H[i-1]:
        H[i-1] -= 1

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

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

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

flg = 1
for i in range(N-1):
    if H[i+1] - 1 >= H[i]:
        H[i+1] -= 1
    elif H[i+1] < H[i]:
        flg = 0
        break
if flg == 1:
    print('Yes')
elif flg == 0:
    print('No')

Solution (Python):
import sys

n=int(input())
h=list(map(int,input().split()))
h=h[::-1]
be=h[0]

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

Solution (Python):
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")

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

before = H[0]

for h in H:
    if before > h:
        print("No")
        break
    if before < h:
        before = h - 1
    if before == h:
        before = h
else:
    print("Yes")

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

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

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

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
h.reverse()
jud = 1
for i in range(n-1):
    if h[i] - h[i+1] == -1:
        h[i+1] -= 1
    elif h[i] - h[i+1] < -1:
        jud = 0
if jud == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
H=list(map(int, input().split()))
L=[float('inf')]*N
L[N-1]=H[N-1]
for i in range(1,N):
  a=H[N-i-1]
  if a-1>L[N-i]:
    print('No')
    exit()
  L[N-i-1]=min(a,L[N-i])
else:
  print('Yes')

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
con=l[0]-1

for i in range(n-1):
  con=max(con,l[i])
  if l[i]-l[i+1]>1:
    print("No")
    exit()
  if l[i]>l[i+1] and l[i+1]<con-1:
    print("No")
    exit()
print("Yes")

Solution (Python):
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")

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

f = False 
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] > 1:
        print("No")
        exit()
    elif H[i-1] - H[i] == 1 and not f:
        f = True
    elif H[i-1] - H[i] == 1 and f:
        print("No")
        exit()
    elif H[i-1] - H[i] == 0:
        pass
    elif H[i-1] - H[i] < 0:
        f = False
print("Yes")

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

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

Solution (Python):
n = int(input())
height_lists=list(map(int, input().split()))
for i in range(1,n):
    
    
    
    if height_lists[i-1] < height_lists[i]:
        height_lists[i] -=1
    else:
        pass
cp_list = height_lists.copy()
cp_list.sort()



if cp_list == height_lists:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
for i in range(1,n):
    if h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass
l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

judge = 0
for i in range(n):
  if a[i] < judge:
    print("No")
    break
  judge = max(judge, a[i]-1)
else:
  print("Yes")

Solution (Python):
n = int(input())
hn = [int(num) for num in input().split()]

for i in range(n-1,0,-1):
  if hn[i-1] > hn[i]:
    hn[i-1] -= 1
    if hn[i-1] > hn[i]:
      print("No")
      exit()
            
print("Yes")

Solution (Python):
n = int(input())
hn = [int(num) for num in input().split()]

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

Solution (Python):
N = int(input())
H = list(map(lambda h: int(h), input().split(" ")))

maxH = []
for i in range(len(H)):
  if i == 0:
    maxH.append(H[i])
  else:
    maxH.append(max([H[i],maxH[i-1]]))

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

print("No") if impossible else print("Yes")

Solution (Python):
n = int(input())
hl = list(map(int,input().split()))

max_num = 0
for i in range(n):
    if hl[i] + 1 < max_num:
        print('No')
        exit()
    max_num = max(max_num, hl[i])
print('Yes')

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

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

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

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

check=0
for i in h:
	if check-1>i:
		print("No")
		exit()
	check=max(check,i)
print("Yes")

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

Solution (Python):
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
a=ll()
a[0]-=1
for i in range(1,n):
    if(a[i]-1>=a[i-1]):
        a[i]-=1
f=0        
for i in range(1,n):
    if(a[i]<a[i-1]):
        f=1
        break
if f:
    print("No")
else:
    print("Yes")

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

Solution (Python):
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")

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

Solution (Python):
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    flag = 0
    for i in range(1, N):
        if H[i*-1-1] > H[i*-1]:
            if H[i*-1-1]-1 == H[i*-1]:
                H[i*-1-1] -= 1
            else:
                flag = 1
    print("Yes" if flag==0 else "No")
resolve()

Solution (Python):
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
    elif H[i]<H[i+1] :
        c=0
print(ans)

Solution (Python):
n = int(input())
al = list(map(int, input().split()))
cnt = len(al)
tmp = al[cnt-1]

for i in range(cnt-1, 1, -1):
    if al[i-1] - tmp >= 2:
        print("No") 
        exit()
    elif al[i-1] - tmp == 1:
        tmp = al[i-1]-1
    else:
        tmp = al[i-1]
print("Yes")

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

flag = True

x = h[0] - 1

for i in range(1, n):
    if h[i] < x:
        flag = False
        break
    elif h[i] == x:
        pass
    else:
        x = h[i] - 1
    
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    h = list(map(int, input().split()))
    k = h[0] - 1
    for i in h[1:]:
        if i < k: 
            print("No")
            exit()
        if i == k:
            pass
        else:
            k = i - 1
    print("Yes")

if __name__=="__main__":
    main()

Solution (Python):
n=int(input())
h=list(map(int,input().split()))
num=h[0]
for i in range(1,n):
    if h[i]<num:
        print("No")
        exit()
    else:
        if h[i]>num:
            num=h[i]-1
print("Yes")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))



for i in range(N-1):
    
    if A[i] - A[i+1] >=2:
        print('No')
        break
    
    if A[i] - A[i+1] ==1 and i >=2 and A[i-1] >= A[i]:
        print("No")
        break
    
    if i ==0 or A[i] > A[i-1]:
        A[i] -=1
        
else:
    print('Yes')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
t = 1
for h in H:
    if t < h:
        t = h-1
    elif t == h:
        pass
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
H = list(map(int,input().split()))

h_max = 0
for i in range(len(H)):
    if i == 0:
        h_max = H[i]
    else:
        if h_max <= H[i]+1:
            if h_max < H[i]:
                h_max = H[i]
        else:
            print ("No")
            exit ()

print ("Yes")

Solution (Python):
def solve():
    n = int(input())
    s = list(map(int, input().split()))
    flg = True
    ma = 0
    for ss in s:
        ma = max(ma, ss)
        if ma - 1 > ss:
            flg = False
    print("Yes" if flg else "No")


solve()

Solution (Python):
input()
tmp = 1
for i in map(int, input().split()):
    if tmp <= i:
        tmp = i
    elif tmp <= i + 1:
        tmp = i + 1
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
for i in range(1,n):
  if h[i-1]<h[i]:
    h[i]-=1
  if h[i-1]>h[i]:
    print('No')
    exit()
print('Yes')

Solution (Python):
import re
import sys
from collections import *
from functools import lru_cache
from heapq import *
from itertools import *
from statistics import *
from string import (ascii_lowercase as lcletters,
                    ascii_uppercase as ucletters,
                    ascii_letters as letters,
                    digits)

hexdigits='01234567890ABCDEFabcdef'

inf=float('inf')

sys.setrecursionlimit(2**31-1)

rfs=lambda:rl().split()
ri=lambda:int(rl())
ris=lambda:list(map(int,rfs()))
rl=lambda:next(sys.stdin)
rrs=lambda:list(map(str.strip,sys.stdin))
rs=lambda:rl().strip()
rt=lambda:sys.stdin.read()
rg=lambda:list(map(list,rrs()))

def n4(i,j):
    return [
                (i-1,j),
        (i,j+1),        (i,j-1),
                (i+1,j),
    ]

def n8(i,j):
    return [
        (i-1,j-1),(i-1,j),(i-1,j+1),
        (  i,j-1),        (  i,j+1),
        (i+1,j-1),(i+1,j),(i+1,j+1),
    ]

inb=lambda i,j,m,n:0<=i<m and 0<=j<n



N=ri()
H=ris()

ok=True
for i in range(N-2,-1,-1):
    x,y=H[i],H[i+1]
    if x-1>y:
        ok=False
        break
    elif x-1==y:
        H[i]-=1

if ok:
    print('Yes')
else:
    print('No')

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

Solution (Python):
import numpy as np
N = int(input())
l = np.array(list(map(int,input().split())))
ans = 'Yes'
M = l[0]

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

    if l[i]< M-1:
        ans ='No'
        break
print(ans)

Solution (Python):
n=int(input())
h=list(map(int,input().split()))
flag=False
h[0]-=1

for i in range(1,n):
  if h[i-1]<=h[i]-1:
    h[i]-=1
  elif h[i-1]==h[i]:
    pass
  else:
    flag=True
    break
    
if flag:
  print('No')
else:
  print('Yes')

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
ans = 'Yes'
max = 0

for i in range(n):
  if h[i] > max:
    max = h[i] - 1
  elif h[i] < max:
    ans = 'No'
    break
    
print(ans)

Solution (Python):
n,*h=map(int,open(0).read().split())

cur=0
for height in h:
    if cur>height:
        print('No')
        exit(0)
    
    if cur==height:
        continue

    cur=height-1

print('Yes')

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
h.reverse()
for i in range(n-1):
  if h[i]<h[i+1]:
    h[i+1]-=1
h.reverse()
for j in range(n-1):
  if h[j]>h[j+1]:
    print('No')
    exit()
else:
  print('Yes')

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *h = map(int, read().split())
    for i1 in range(n - 1, 0, -1):
        if h[i1] >= h[i1-1]:
            pass
        elif h[i1] == h[i1-1] - 1:
            h[i1-1] -= 1
        else:
            print('No')
            sys.exit()
    print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
H = list(map(int,input().split()))




flag = True

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

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    pre = A[0]
    for i in A:
        if pre > i:
            print("No")
            return
        elif pre < i:
            pre = i -1
    print("Yes")        
if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
*H,=map(int,input().split())

for i in range(-1,-len(H),-1):
   
   if H[i]<H[i-1]-1:
    print('No')
    break
   if H[i-1]-1 == H[i]:
    H[i-1]=H[i]
else:
   print('Yes')

Solution (Python):
N = int(input())
h0 = 0
for h in map(int, input().split()):
    if h0 < h:
        h0 = h-1
    elif h0 == h:
        continue
    else:
        print("No")
        exit()
print("Yes")

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

res = True

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

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N = I()
H = LI()



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

Solution (Python):
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
  elif h[i+1] < h[i]:
    print('No')
    exit(0)
print('Yes')

Solution (Python):
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]:
        flag = False
    
    else:
        if squeres[i] < squeres[i + 1]:
            before_down = 0
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
H = list(map(int, input().split()))
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')

Solution (Python):
def check():
  N = int(input())
  H = list(map(int, input().split()))
  for i in range(N-1):
    if H[i]>H[i+1]+1:
      return 'No'
    if H[i]==H[i+1]+1:
      H[i+1] += 1
  return 'Yes'
print(check())

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




import sys
flg=0
for i in range(n-1):
  if h[i+1]-h[i]<=-2:
    print("No")
    sys.exit()
  elif h[i+1]-h[i]==-1 and flg==1:
    print("No")
    sys.exit()
  elif h[i+1]-h[i]==-1 and flg==0:
    flg=1
  elif h[i+1]-h[i]!=0:
    flg=0
print("Yes")

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
a = 0

for h in H:
  if h<a:
    print("No")
    exit()
  a = max(a,h-1)

print("Yes")

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

base = 0
for h in H:
    if(base > h):
        print("No")
        break
    base = max(base, h-1)
else:
    print("Yes")

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

h.reverse()

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

    elif h[i] == h[i+1] - 1:
        h[i+1] -= 1

    else:
        print('No')
        exit()

print('Yes')

Solution (Python):



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


is_ok = True

if N>1:
    tmp_height = h_list[-1]
    for i in range(N-2, -1, -1):
        if h_list[i]>tmp_height:
            h_list[i] -= 1
        if not h_list[i]<=tmp_height:
            is_ok = False
            break
        tmp_height = h_list[i]


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

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
h = h[::-1]

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

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
can_build = True
for i in range(n-1, 0, -1):
    diff = h[i-1] - h[i]
    if diff == 1:
        h[i - 1] -= 1
    elif diff > 1:
        can_build = False
        break
print("Yes" if can_build else "No")

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
ma = A[0]
for i in range(1,n):
    if ma < A[i]:
        A[i] -= 1
    if ma <= A[i]:
        ma = A[i]
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
H.reverse()
def main():
  for i in range(N-1):
    if (H[i+1] - H[i] >= 2):
      print("No")
      return
    if (H[i+1] - H[i] == 1):
      H[i+1] -= 1
  print("Yes")

main()

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
lis[0]-=1
for i in range(n-1):
  if lis[i] < lis[i+1]:
    lis[i+1] -= 1
  elif lis[i] > lis[i+1]:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
flag = 0
hmax = H[0]
for i in range(1,N):
    h = H[i]
    if hmax-h>=2:
        flag = 1
        break
    hmax = max(hmax,h)
if flag==0:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    N = int(input())
    H = [int(i) for i in input().split()]

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

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


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
H = list(map(int, input().split()))[::-1]
ok = True
for i in range(n-1):
    if H[i] >= H[i+1]: continue
    if H[i] >= H[i+1]-1:
        H[i+1] -= 1
    else:
        ok = False
        break
print("Yes" if ok else "No")

Solution (Python):
n = int(input())
H = list(map(int, input().split()))
for i in range(1, n):
    if H[i] < H[i-1]:
        print('No')
        exit()
    else:
        if H[i] > H[i-1]:
            H[i] -= 1
else:
    print('Yes')

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
p = 0
for i in a:
  if p > i:
    print('No')
    exit()
  if p < i:
    p = i - 1
print('Yes')

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush

from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): 
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    

    N = int(input())
    
    A = list(map(int, input().split())) 
    
    
    cur=0
    for i,a in enumerate(A):
        if cur>a:
            print('No')
            return
        elif cur==a:
            continue
        else:
            a-=1
            cur=a
    print('Yes')




if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
L= list(map(int,input().split()))
p = "Yes"
a = L[0]
for i in range(n-1):
  if L[i+1]+1 < a:
    p = "No"
  if a < L[i+1]:
    a = L[i+1]
print(p)

Solution (Python):
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:
            
            
            H[i+1] += 1
        else:
            print('No')
            break
else:
    print('Yes')

Solution (Python):
import sys
n = int(input())
h = list(map(int,input().split()))
for i in range(n-1,0,-1):
    if h[i]-h[i-1]>=0:
        pass
    elif h[i]-h[i-1]==-1:
        h[i-1] -= 1
    else:
        break
else:
    print("Yes")
    sys.exit()
print("No")

Solution (Python):
n = int(input())
h = [int(xi) for xi in input().split()]

stock = 0
ans = "Yes"

for xi in range(n-1):
    stock += h[xi+1]-h[xi]
    if stock<0:
        ans = "No"
        break
    if stock>1: stock=1

print(ans)

Solution (Python):
N = int(input())
Hs = list(map(int, input().split()))

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

for i in reversed(range(N - 1)):
    if(Hs[i+1] - Hs[i] >= 0):
        continue

    elif(Hs[i+1] - Hs[i] == -1):
        Hs[i] -= 1
        continue

    else:

        print("No")
        exit()


print("Yes")

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
ans = "Yes"
bf_max = 0
for now in h:
    if bf_max <= now-1:
        bf_max = now - 1
    elif bf_max <= now:
        bf_max = now
    else:
        ans = "No"
        break


print(ans)

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
base=0
for h in H:
    if base>h:
        print("No")
        break
    base=max(base,h-1)
else:
    print("Yes")

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

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

Solution (Python):
N=int(input())
h=list(map(int,input().split()))
while len(h)>=2:
    if h[0]-h[1]>=2:
        print("No")
        break
    else:
        if h[0]<=h[1]:
            h.pop(0)
        else:
            h.pop(1)
if len(h)<=1:
    print("Yes")
else:
    pass

Solution (Python):

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

cur = 0
flag = True
for i in range(N):
    cur = max(cur, X[i])
    if cur - X[i] > 1:
        flag = False

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

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

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