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):
from sys import exit
n = int(input())
hh = list(map(int, input().split()))

for i in range(n-1,0,-1):
    if hh[i] >= hh[i-1]:
        continue
    else:
        hh[i-1] -= 1
        if hh[i] >= hh[i-1]:
            continue

        print('No')
        exit()
print('Yes')

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

Solution (Python):

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

cnt = 0
for i in range(n-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()))
minh = h[-1]
for i in range(n - 2, -1, -1):
    if h[i] > minh + 1:
        print("No")
        exit()
    minh = min(minh, h[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 - 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()))
if n==1: print('Yes');exit()
H[0]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No');exit()
    elif H[i]==H[i+1]:
        continue
    else:
        H[i+1]-=1
print('Yes')

Solution (Python):
input();a=list(map(int,input().split()))
for i,j in zip(a,sorted(a)):
  if abs(i-j)>1: print('No');break
else:
  print('Yes')

Solution (Python):
input();a=list(map(int,input().split()));b=sorted(a)
for i,j in zip(a,b):
  if abs(i-j)>1: print('No');break
else:
  print('Yes')

Solution (Python):
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
for i in range(n-1):
  if h[i]>h[i+1]:
    ans='No'
print(ans)

Solution (Python):
N=int(input())
arr=list(map(int,input().split()))
ans=1
kari=1
for i in range(N-1):
    kari=max(kari,arr[i]-1)
    
    if kari>arr[i+1]:
        ans=0
        
        break


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

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

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

        if h[i] > h[i+1]:
            print("No")
            exit()

print("Yes")

Solution (Python):
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    if n == 1:
        print("Yes")
        return
    h = list(map(int, readline().rstrip().split()))
    for i in range(n - 1):
        right = h[n - i - 1]
        left = h[n - i - 2]
        if left == right + 1:
            h[n - i - 2] -= 1
        if left > right + 1:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()

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

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

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

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

ans = True
for i in range(len(H) - 1):
    if H[i] + 1 == H[i + 1]:
        H[i + 1] -= 1
    if H[i] + 1 < H[i + 1]:
        ans = False
        break

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

Solution (Python):
n = int(input())
H = list(map(int, input().split()))
b = -1
for h in H:
    if b > h:
        if b != h+1:
            print("No")
            exit()
        else:
            b = h+1
    else:
        b = h

print("Yes")

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

def main(n,h):
    hr=list(reversed(h))
    for i in range(n-1):
        if hr[i]<hr[i+1]:
            if hr[i+1]-hr[i]>1:
                return 'No'
            else:
                hr[i+1]-=1
    return 'Yes'

if __name__=='__main__':
    n,h=readinput()
    ans=main(n,h)
    print(ans)

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

print(ans)

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

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

    if Hi[i] > Hi[i+1] :
        print('No')
        exit()

print('Yes')

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

if N==1:print('Yes')
else:
  MAX=H[0]
  ok=1
  for i in range(1,N):
    if H[i]>MAX:MAX=H[i]
    if H[i]<=MAX-2:
      ok=0
      break
  if ok==1:print('Yes')
  else:print('No')

Solution (Python):
n = int(input())
h = [int(i) for i in 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())
h = [int(i) for i in input().split()]
ans = 'Yes'
for i in range(n - 1, 0, -1):
    if h[i - 1] > h[i]:
        h[i - 1] -= 1
    if h[i - 1] > h[i]:
        ans = 'No'
print(ans)

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

Solution (Python):
N = int(input())
hhh = list(map(int, input().split()))
flag = True
for i in range(N - 1):
    if hhh[i] < hhh[i + 1]:
        flag = True
    elif hhh[i] == hhh[i + 1]:
        pass
    elif (hhh[i] == hhh[i + 1] + 1) and flag:
        flag = False
    else:
        print('No')
        exit()
print('Yes')

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

ans = "Yes"
t = h[0]
for i in range(1,n):
    t = max(h[i-1],t)
    if h[i] - t <= -2:
        ans = "No"
        break

print(ans)

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

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

l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input()) 
c=list(map(int, input().split())) 
ans = 0
 
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-1):
        if c[i] > c[i+1] +1:
            print('No')
            exit()
        if c[i] == c[i+1] +1:
            ans = max(ans,c[i])
            if c[i+1] + 1 < ans:
                print('No')
                exit()


print('Yes')

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

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

isOK=True
for i in range(n-1,0,-1):
    diff=H[i-1]-H[i]
    if diff<1:
        pass
    elif diff==1:
        H[i-1]-=1
    else:
        isOK=False
        break

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

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

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

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

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i + 1] >= 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys

n = int(input())
h = list(map(int, input().split()))
max_ = h[0]

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i + 1] >= 2:
        print("No")
        sys.exit()
print("Yes")

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

Solution (Python):
N = int(input())
F = [int(x) for x in input().split()]

flag = True
for i in range(N-1):
    if F[i] < F[i+1]:
        F[i+1] -= 1
    elif F[i] > F[i+1]:
        flag = False
        break
    
if flag == True:
    print("Yes")
else:print("No")

Solution (Python):
import sys
n=int(input())
hlist=list(map(int,input().split()))

for i in range(1,n):
	if hlist[-i] == hlist[-(i+1)] - 1:
		hlist[-(i+1)] -= 1
	elif hlist[-(i+1)] > hlist[-i]:
		print('No')
		sys.exit()

print("Yes")

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

m = 0
for i in h:
    m = max(i, m)
    if i < m-1:
        ans = 'No'
        break
else:
    ans = 'Yes'

print(ans)

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
max_h = H[0]
flag = 0

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

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

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

w=sorted(h)
flag=0
for i in range(n):
  if abs(h[i]-w[i])<=1:
    continue
    
  else:
    flag=1
    break
if flag==1:
  print('No')
  
else:
  print('Yes')

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

Solution (Python):
n = int(input())
m=list(map(int,input().split()))
k=0
r=0
for i in range(n):
    if m[i]<k:
        r=1
        break
    k=max(k,m[i]-1)
if r==1:
    print('No')
else:
    print('Yes')

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

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

MAX=H[0]

for n in range(N):
    if MAX-H[n]>=2:
        print("No")
        break
    else:
        MAX=max(MAX,H[n])
else:
    print("Yes")

Solution (Python):
def main():
    n = int(input())
    hlis = list(map(int, input().split()))

    for i in range(0, n-1):
        if hlis[i]-1 > hlis[i+1]:
            print("No")
            exit()
        elif hlis[i]-1 == hlis[i+1]:
            hlis[i] = hlis[i] - 1
            if i > 1 and hlis[i-1] > hlis[i]:
                print('No')
                exit()
        elif i > 1 and hlis[i-1] <= hlis[i] - 1:
            hlis[i] = hlis[i]-1
    print("Yes")

if __name__ == "__main__":
    main()

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

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

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

Solution (Python):







__giturl__ = "$URL$"


from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


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

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


if(__name__ == '__main__'):
  main()

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    h = LI()
    for i in range(n-1, 0, -1):
        diff = h[i] - h[i-1]
        if diff >= 0:
            continue
        elif diff == -1:
            h[i-1] -= 1
        else:
            print("No")
            sys.exit()
    print("Yes")

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)



from collections import deque

import itertools
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    H =list(map(int,input().split()))
    off = 0
    flag =1
    for i in range(N-1,0,-1):
        if H[i] - off >=H[i-1]:
            off =0
            continue
        elif H[i]-off +1 == H[i-1]:
            off =1
        else:
            print("No")
            exit()

    print("Yes")




if __name__ == "__main__":
    main()

Solution (Python):
def resolve():
    N = int(input())
    H = list(reversed([int(i) for i in input().split()]))
    for i in range(N - 1):
        if H[i + 1] > H[i] + 1:
            print("No")
            return
        elif H[i + 1] == H[i] + 1:
            H[i + 1] -= 1
    else:
        print("Yes")


resolve()

Solution (Python):
n = int(input())
xs = [int(x) for x in input().split()]

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

print('Yes' if sorted(xs) == xs else 'No')

Solution (Python):
import sys

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:
        print('No')
        sys.exit()
    elif H[i+1] - H[i] == 1:
        H[i+1] -= 1
    else:
        pass    

print('Yes')

Solution (Python):

N = int(input())
H = list(map(int, input().split()))
ans = 0
for n in range(N):
    if ans - 1 > H[n]:
        print("No")
        exit()
    ans = max(ans,H[n])
print("Yes")

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

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

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

Solution (Python):
n = int(input())
lh = [int(w) for w in input().split()]

cond = True
nh = lh[0]-1
for i in range(1, n):
    if lh[i] == nh:
        continue
    elif lh[i] > nh:
        nh = lh[i]-1
        continue
    else:
        cond = False
        break

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

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

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
lis=list(reversed(lis))
st=lis[0]
for i in range(n-1):
    if lis[i+1]>lis[i]+1:
        print("No")
        sys.exit()
    elif lis[i+1]==lis[i]+1:
        lis[i+1]-=1
    else:
        continue
print("Yes")

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

Solution (Python):
N = int(input())

H = list(map(int, input().split()))
for i in range(1,N+1):
    tmp = H[-i]
    if not i==N:
        if tmp < H[-i-1]:
            if tmp == H[-i-1]-1:
                H[-i-1] -= 1
            else:
                print('No')
                exit()
print('Yes')

Solution (Python):
N = int(input())

H = list(map(int, input().split()))
flg = False
for i in range(1,N+1):
    if flg:
        tmp = H[-i]-1
    else:
        tmp = H[-i]
    flg = False
    if not i==N:
        if tmp < H[-i-1]:
            if tmp == H[-i-1]-1:
                flg = True
            else:
                print('No')
                exit()
print('Yes')

Solution (Python):
N, *A = map(int, open(0).read().split())
pre = A[-1]
for i in range(N-1, -1, -1):
    a = A[i]
    if pre < a-1:
        print('No')
        exit()
    elif pre < a:
        pre = a-1
    else:
        pre = a
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()
H = readInts()
ma = H[0]
for i in range(1,n):
    if ma < H[i]:
        H[i] -= 1
    if ma <= H[i]:
        ma =  H[i]
    else:
        print('No')
        exit()
print('Yes')

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



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

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

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

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

down = False
p = -1
for h in H:
    if p - h >= 2:
        print('No')
        exit()
    if down and p - h >= 1:
        print('No')
        exit()
    if p < h:
        down = False
    elif p > h:
        down = True
    p = h
print('Yes')

Solution (Python):
n = int(input())
h = list(map(int, input().split()))[::-1]
ans = "Yes"
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:
        ans = "No"
        break
print(ans)

Solution (Python):
import sys

n = int(input())
h = list(map(int, input().split(' ')))
max = 0
for i in range(len(h)):
    if max < h[i]:
        max = h[i]
    if h[i]+2 <= max:
        print('No')
        sys.exit()
print('Yes')

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

for i in range(len(H)-2, -1, -1):
    if H[i] - H[i+1] == 1:
        H[i] -= 1
    elif  H[i] - H[i+1] >= 2:
        print("No")
        exit()
    else:
        continue

print("Yes")

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        H=list(map(int,input().split()))
        H.reverse()
        val=H[0]
        for i in range(1,n):
            if val>=H[i]:
                val=H[i]
            elif val==H[i]:
                continue
            elif H[i]-val==1:
                continue
            else: return 'No'
        return 'Yes'
    print(main())

    
resolve()

Solution (Python):
def resolve():

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


resolve()

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

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

if any(li[i] > li[i+1] for i in range(n-1)):
    print("No")
else:
    print("Yes")

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

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

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

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

C=[H[0]]
for i in range(1,N):
    if H[i-1]!=H[i]:
        C.append(H[i])
        
for i in range(len(C)-1):
    if C[i]>C[i+1]:
        C[i]-=1

F=True
for i in range(len(C)-1):
    F&=(C[i]<=C[i+1])

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

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

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

Solution (Python):


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

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

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

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

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

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

Solution (Python):

def solve():
    ans = "Yes"
    for i in range(1,N-1):
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                ans = "No"
                break
            if H[i-1] > H[i]:
                ans = "No"
                break
        elif H[i-1] <= H[i]-1:
            H[i] -= 1
    print(ans)

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

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

Solution (Python):
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    lower = True
    for i in range(N-1):
        if H[i] > H[i+1]:
            if H[i] - H[i+1] == 1 and lower is True:
                lower = False
            else:
                print("No")
                return
        elif H[i] == H[i+1]:
            pass
        else:
            lower = True

    print("Yes")


    
if '__main__' == __name__:
    resolve()

Solution (Python):
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
H = rl()

last = H.pop()
while H:
	h = H.pop()
	if h > last+1:
		print('No')
		exit()
	elif h > last:
		h -= 1
	last = h
print('Yes')

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

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

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

for i in range(n-2, -1, -1):
    if n == 1:
        break
    if a[i] - a[i+1] >= 2:
        flg = False
        break
    elif a[i] - a[i+1] == 1:
        a[i] -= 1
print('Yes') if flg else print('No')

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

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

ans = 'Yes'
last_h = H[-1]
for h in reversed(H):
    if h - last_h > 1:
        ans = 'No'
        break
    elif h - last_h == 1:
        last_h = h - 1
    else:
        last_h = h

print(ans)

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
ans = "Yes"
max_n = 0


for i in li:
    if i < max_n - 1:
        ans = "No"
        break
    max_n = max(i,max_n)
print(ans)

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

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

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

Solution (Python):


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

Solution (Python):
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    H[0] -= 1
    for i in range(1, N - 1):
        if H[i-1] < H[i]:
            H[i] -= 1
        if H[i] > H[i+1]:
            print('No')
            break
    else:
        print('Yes')
    return

main()

Solution (Python):

n, *h = map(int, open(0).read().split())
for i in range(1, n):
    if h[-i] < h[-i - 1]:
        h[-1 - i] -= 1
        if h[-i] < h[-i - 1]:
            print("No")
            exit()
print("Yes")

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

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

curr = hl[0]-1
for i in range(1,n):
    if hl[i] > curr:
        curr = hl[i]-1
    elif hl[i] == curr:
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
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-2, 0, -1):
    if h[i] >= h[i+1] + 2:
        print("No")
        exit()
    elif h[i] > h[i+1]:
        h[i] -= 1

print("Yes")

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

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

print('Yes')

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

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

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

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

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

print('Yes')

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

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

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

if len(h) == 1 :
    print("Yes")
else :
    h.reverse()
    for i in range(n-1):
        if h[i] < h[i+1] :
            h[i+1] -= 1
            if h[i] < h[i+1] :
                print("No")
                break
    else :
        print("Yes")