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):
def solve(string):
    n, *h = map(int, string.split())
    curr = None
    for _h in h[::-1]:
        if curr is None:
            curr = _h
            continue
        if _h <= curr:
            curr = _h
            continue
        if _h - 1 == curr:
            continue
        return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

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

result = "Yes"

for i in range( N-2, -1,-1):
  if list[i] > list[i+1]:
    list[i] -=1
    if list[i] > list[i+1]:
      result = "No"
      break

print(result)

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

    h = list(reversed(h))
    flag = True

    for i in range(1,len(h)):
        if h[i] - h[i-1] > 1:
            flag = False
        elif h[i] - h[i-1] == 1:
            h[i] -= 1
        
    if flag:
        print('Yes')
    else:
        print('No')

main()

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

c = 0
for i in range(n-1):
    if h[i] <= h[i+1]-1:
        h[i+1] = h[i+1]-1
    elif h[i] == h[i+1]:
        continue
    else:
        c = 1
if c == 1:
    print('No')
else:
    print('Yes')

Solution (Python):
N = int(input())
inputs = input().split()
nums = [int(n) for n in inputs]

def hoge(nums):
    for i in range(len(nums)-1, 0, -1):
        temp = nums[i] - nums[i-1]
        if temp < 0:
            if temp == -1:
                nums[i-1] = nums[i-1] - 1
            else:
                return 'No'
    return 'Yes'

result = hoge(nums)
print(result)

Solution (Python):

import sys

n=int(raw_input())
h=map(int,raw_input().split())
for i in xrange(n-2,-1,-1):
 if h[i+1]>=h[i]:
  continue
 elif h[i]-h[i+1]==1:
  h[i]-=1
 else:
  print 'No'
  sys.exit()
print 'Yes'

Solution (Python):
N = int(input())
H = list(map( int, input().split()))
def solve():
  for i in range(N-1, 0, -1):
    if H[i-1]-H[i]>1:
      return False
    if H[i-1]-H[i]==1:
      H[i-1]-=1
  return True

print('Yes' if solve() else 'No')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
assert len(H) == N
for i in range(N - 2, -1, -1):
    if H[i] > H[i + 1]:
        H[i] -= 1
yes = all(a <= b for a, b in zip(H, H[1:]))
print('Yes' if yes else 'No')

Solution (Python):
N = int(input())
H_list = [int(h) for h in input().split()]

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

else:
    decrease_allowed = True
    for i in range(N-1):
        h_current = H_list[i]
        h_next = H_list[i +1]
        if decrease_allowed:
            max_grad = h_next - h_current + 1
        else:
            max_grad = h_next - h_current
        
        if max_grad > 0:
            decrease_allowed = True
        elif max_grad == 0:
            decrease_allowed = False
                
        else:
            print('No')
            break
            
        if i == N - 2:
            print('Yes')

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

M = H[0]
for i in range(0, N-1):
    if H[i+1] < M:
        print('No')
        quit()
    if H[i+1] - H[i] > 1:
        H[i+1] -= 1
        M = max(H[i+1], M)
print('Yes')

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
c=0
for i in b:
    if c>i:
        print("No")
        exit()
    elif c<i:
        c=i-1
print("Yes")

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

state = 0
for i in range(1,len(H))[::-1]:
    if H[i]<H[i-1]:
        H[i-1] = H[i-1] -1

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

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

N = int(input())
H = [int(item) for item in input().split()]

c_height = -1
for h in H:
    if h - 1 >= c_height:
        c_height = h - 1
    elif h == c_height:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

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

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

ans = "Yes"

if n != 1:
  for i in range(n-1):
    if h[i]-1>h[i+1]:
      ans = "No"
      break
    elif h[i]-1==h[i+1]:
      h[i+1] += 1
      
print(ans)

Solution (Python):
n = int(input())
stairs = [int(x) for x in input(). split()]
 
minHeight = max(stairs[0] - 1, 0)
result = True

for i in stairs:
    if i < minHeight:
        result = False
        break
    else:
        if i > minHeight:
    	    minHeight = i - 1
 
if result:
    print("Yes")
else:
    print("No")

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

result = True
for i in range(n):
    if n == 1:
        break
    
    pos = ""
    if (i == 0):
        if (h[i] > h[i+1]):
            h[i] -= 1
    elif (i == (n-1)):
        if (h[i] > h[i-1]):
            h[i] -= 1
    else:
        if (h[i] > h[i+1]) | (h[i] > h[i-1]):
            h[i] -= 1
    
    if (i != 0):
        if(h[i] < h[i-1]):
            result = False
            break

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

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

for i in h:    
    if highest - i > 1:
        print("No")
        exit()
    highest = max([i,highest])

print("Yes")

Solution (Python):
n=int(input())
h=[int(i) for i in input().split()]
p=-10**101
for i in range(n):
    if p>h[i]:
        if p!=h[i]+1:
            print("No")
            exit()
        else:
            p=h[i]+1
    else:
        p=h[i]
print("Yes")

Solution (Python):
num = int(input())
num_list = input().split(' ')
num_list.reverse()
num_list[0] = int(num_list[0])
for i in range(num):
    if i + 1 == num:
        print('Yes')
        break
    num_list[i+1] = int(num_list[i+1])
    if num_list[i] >= num_list[i+1]:
        continue
    else:
        if num_list[i] + 1 == num_list[i+1]:
            num_list[i+1] = num_list[i+1] -1
        else:
            print('No')
            break

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

Solution (Python):

def hoge(lst,i):
    if lst[i]==lst[i+1] and len(lst)>i+2:
        return hoge(lst,i+1)
    if lst[i]>lst[i+1]:return True
    if lst[i]<lst[i+1]:return False

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

for i in range(N-1):
    if H[i]-1>H[i+1]:
        det+=1
        print("No")
        break
    if i+2<=N-1:
        if H[i]>H[i+1] and H[i+1] > H[i+2]:
            det+=1
            print("No")
            break
        if H[i]>H[i+1] and hoge(H,i+1):
            det+=1
            print("No")
            break
if det==0:print("Yes")

Solution (Python):





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

for i in h:    
    if highest - i > 1:
        print("No")
        exit()
    highest = max([i,highest])

print("Yes")

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

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

for i in range(N - 2, -1, -1):
    if arr[i] > arr[i + 1]:
        arr[i] -= 1
        if arr[i] > arr[i + 1]:
            print('No')
            break
else:
    print('Yes')

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

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-1]:
        H[i]-=1
    if H[i-1] > H[i]:
        ans = 'No'
        break
print(ans)

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

Hmax = H[0]
flag = 0
for i in range(N):
	if H[i] < Hmax - 1:
		flag = 1
		break
	if H[i] > Hmax:
		Hmax = H[i]

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, H: "List[int]"):
    for i in range(len(H)-1)[::-1]:
        if H[i] > H[i+1]:
            H[i] = H[i] - 1
    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            return NO
    return YES



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    H = [ int(next(tokens)) for _ in range(N) ]  
    print(solve(N, H))

if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

N = int(input())
H = [int(x) for x in input().split()]

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

Solution (Python):
input()
inp = input().strip().split(' ')
inp = [int(v) for v in inp]
flg = 'Yes'
for i in reversed(range(len(inp) - 1)):
    if inp[i] - inp[i + 1] == 1:
        inp[i] -= 1
    elif inp[i + 1] >= inp[i]:
        a = 1
    else:
        flg = 'No'
        break
print(flg)

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

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

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

c = 0
for i in range(N-1):
    if H[i+1]-H[i] < 0:
        c += 1
        break

print("Yes" if c==0 else "No")

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

for i in h:
    if check - 1 <= i:
        check = max(check, i)
    else:
        print('No')
        exit()

print('Yes')

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

for i, v in enumerate(arr):
  if i == 0:
    arr[i] = v - 1
  else:
    if v - arr[i-1] > 0:
      arr[i] = v - 1
    elif v - arr[i-1] < 0:
      print("No")
      break
else:
  print("Yes")

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

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

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

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

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

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

minn = 1
maxn = 10**9

lmax_list = [minn for i in range(N)]
rmin_list = [maxn for i in range(N)]

lmax_list[0] = h_list[0]
rmin_list[N-1] = h_list[N-1]
for i in range(1, N):
    h = h_list[i]
    if h > lmax_list[i-1]:
        lmax_list[i] = h
    else:
        lmax_list[i] = lmax_list[i-1]

for i in range(N-2)[::-1]:
    h = h_list[i]
    if h < rmin_list[i]:
        rmin_list[i] = h
    else:
        rmin_list[i] = rmin_list[i+1]

diff_list = [ lmax_list[i] - rmin_list[i+1] for i in range(N-1)]

if len(diff_list) > 0 and max(diff_list) > 1:
    print("No")
else:
    print("Yes")

Solution (Python):



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

now=0
for i in h :
    if now==-1 :
        break
    if now < i :
        now=i-1
    elif now > i :
        now = -1

if now != -1 :
    print("Yes")
else :
    print("No")

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

m = 0
for h in H:
    if m-1 <= h:
        m = max(m, h)
    else:
        print("No")
        sys.exit()

print("Yes")

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

m = 0
for h in H:
    if m <= h-1 or m-1 <= h:
        m = max(m, h)
    else:
        print("No")
        sys.exit()

print("Yes")

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

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

for i in range(N-1, 1, -1):
	if Hs[i] - Hs[i-1] < -1:
		print("No")
		exit(0)
	if Hs[i] - Hs[i-1] < 0:
		Hs[i-1] -= 1

for i in range(N-1, 1, -1):
	if Hs[i-1] > Hs[i]:
		print("No")
		exit(0)

print("Yes")

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import bisect

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

def LI(): return list(map(int, sys.stdin.readline().split()))

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

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

tem =0

for i in range(n):

    if(i==0):
        pass
    elif( int(h[-(i+1)]) > 1 + int(h[-i]) - tem ):
        answer = "No"
        break
    elif(int(h[-(i+1)]) == 1 + int(h[-i]) - tem  ):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)

Solution (Python):
N=int(input())
H=[int(i) for i in input().split()]
A=1
if N>1:
    for i in range(N-1):
        if H[-(i+1)-1] <= H[-(i+1)]:
            A+=1
        elif H[-(i+1)-1]-1 == H[-(i+1)]:
            A+=1
            H[-(i+1)-1]-=1
    if A==N:
        print('Yes')
    else:
        print('No')
elif N==1:
    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]:
        h[i - 1] -= 1

ans = 'Yes' if all(h[i] <= h[i + 1] for i in range(0, n - 1)) else 'No'
print(ans)

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
d = 0

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

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

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

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

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

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

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

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

flg = True

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

        if l[i+1] < l[i]:
            flg = False
            break

if flg == True:
    print("Yes")
else:
    print("No")

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

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

for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    H[N-i-2] -= 1
    
f = 0
for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    f = 1
    
if f == 0:
  print("Yes")
else:
  print("No")

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

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

flag = ""

fst = listH[0]

for i in listH[1::]:
	snd = i
	if snd >= fst:
		flag = "Yes"
		fst = i
	elif snd + 1 >= fst:
		flag = "Yes"
		fst = i + 1
	else:
		print("No")
		exit()

print(flag)

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

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

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

Solution (Python):
N = int(input())
li = list(map(int,input().split()))
ans = "Yes"
b = 0
for i in range(N):
        b = max(b,li[i])
        if b > li[i]+1:
        
                ans = "No"
        

print(ans)

Solution (Python):

import sys

def main():
    sys.stdin.readline()
    numbers = [int(i) for i in sys.stdin.readline().strip().split()]
    current = 1
    for i in numbers:
        if current < i:
            current = i -1
        elif current > i:
            print("No")
            return
    print("Yes")
        
if __name__ == "__main__":
    main()

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


def yes():
    print('Yes')
    exit()


def no():
    print('No')
    exit()


minus = [0] * N
while True:
    f = 0
    for i in range(N - 1):
        if H[i] > H[i + 1]:
            f = 1
            if minus[i]:
                no()
            H[i] -= 1
            minus[i] += 1
    if not f:
        yes()

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
r='Yes'
for i in range(n-1):
  if a[-2-i]-a[-1-i]>1:
    r='No'
    break
  elif a[-2-i]-a[-1-i]==1:
    a[-2-i]=a[-2-i]-1
print(r)

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

min=0
ans=True

for i in range(n):
    if l[i]-1>=min:
        min=l[i]-1
    elif l[i]>=min:
        min=l[i]
    else:
        ans=False

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

Solution (Python):
"""
 // Author : snape_here - Susanta Mukherjee
 // Date : 27/07/2019

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    


from math import ceil,floor,log,sqrt,factorial,pow,pi






  



def ii(): return int(input())
def fi(): return float(input())
def si(): return str(input())
def mi(): return map(int,input().split())
def li(): return list(mi())

def main():
    
    N = ii()
    H = li()
    l = 0
    for h in H:
        if l > h:
            print('No')
            break
        if h - 1 > l:
            l = h - 1
    else:
        print('Yes')



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import sys
N = int(input())
H = [int(i) for i in input().split()]
"""H.append(H[-1])
tmp = H[0]
for i in range(1,N):
    if H[i]-tmp ==1:
        H[i]-=1
    if (H[i]-tmp != 0) and (not tmp<=H[i]<=H[i+1]):
        print('No')
        sys.exit()
    tmp = H[i]
print('Yes')"""
Max = H[0]
for i in range(1,N):
    Max = max(Max,H[i-1])
    if not  H[i]>=Max-1:
        print('No')
        sys.exit()

print('Yes')

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

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

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

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

tmp_mas = 0
flag = True
for i in range(N):
    if masu_list[i] >= tmp_mas:
        tmp_mas = masu_list[i]
    elif tmp_mas - masu_list[i] == 1:
        tmp_mas = masu_list[i] + 1
    else:
        print('No')
        flag = False
        break

if flag:
    print('Yes')

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

Solution (Python):
N = int(input())
H = list(map(int, input().split(' ')))
i = 1
a = 0
while i < N:
    if H[i-1] <= H[i]-1:
        H[i] = H[i] - 1
    i += 1
i = 1
while i < N:
    if H[i-1] > H[i]:
        print("No")
        quit()
    i += 1
print("Yes")

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

result =""
i_pre = 1000000000
for i in (reversed(A)):
  if i_pre >= i:
      i_pre = i
  else:
    z = i -1
    if  z <= i_pre:
      i_pre = z
    else:
      result = "No"

if result =="":
  result = "Yes"

print(result)

Solution (Python):
N = int(input())
lis = list(map(int,input().split()))
lis.insert(0,0)
listed = [lis[-i-1]-lis[-i-2] for i in range(len(lis)-1)]
for i in range(len(listed)-1):
  if listed[i] < 0:
    listed[i] += 1
    listed[i+1] -=1
listed.sort()
if listed[0] < 0:
  print('No')
else:
  print('Yes')

Solution (Python):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)








N = int(input())
H = [int(x) for x in input().split()]

c = H[0]
ans = True
for h in H:
    if c <= h:
        c = max(c, h - 1)
    else:
        ans = False
        break

if ans == True:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
lst = [int(i) for i in input().split()]

lst[0] -=1
for i in range(1,len(lst)):
    if (lst[i-1] != lst[i]) or (lst[i-1] > lst[i]):
        lst[i] -= 1

flag = 0
for i in range(len(lst)-1):
    if (lst[i] <= lst[i + 1]) & (flag==0):
        flag = 0
    else:
        flag = 1

if len(lst) == 1:
    flag = 1


if flag == 0:
    print('Yes')
else:
    if len(lst) == 1:
        print('Yes')
    else:
        print('No')

Solution (Python):

a = int(input())
b = list(map(int,input().split()))
ret = "Yes"
cur_bar = b[-1]
for n_1 in b[-2::-1]:
    if cur_bar >= n_1:
        cur_bar=n_1
    elif cur_bar - n_1==-1:
        pass
    else:
        ret = "No"
        break
print(ret)

Solution (Python):
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

n=I()
a=LI()[::-1]

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

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

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

result = 'Yes'

if H[0] >= 1:
    H[0] -= 1

for i in range(N-1):
    diff = H[i+1] - H[i]
    if diff >= 1:
        H[i+1] -= 1
    elif diff == 0:
        pass
    elif diff < 0:
        result = 'No'
        break

print(result)

Solution (Python):
N = int(input())
li = list(map(int,input().split()))
ans = "Yes"
b = 0
for i in range(N):
        b = max(b,li[i])
        if b > li[i]+1:
                ans = "No"
        

print(ans)

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

for i in range(1,N):
    if H[i-1] > H[i]:
        ans = 'No'
        break
    else:
        H[i] = max(H[i-1], H[i]-1)

print(ans)

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


h[0] -= 1

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



for j in range(0, n-1):
    if h[j+1] - h[j] < 0:
        flag = "No"

print(flag)

Solution (Python):


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

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

pre = -1
for i in range(N):
    if pre <= H[i] -1:
        pre = H[i] - 1
    elif pre <= H[i]:
        pre = H[i]
    else:
        output = "No"
        break

print(output)

Solution (Python):
import glob




REL_PATH = 'ABC\\136\\C'


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                self.initialize(path)
                self.resolve()
        except NameError:
            self.resolve()


class C(Common):

    def resolve(self):

        n = int(self.input_data())
        stairs = [int(i) for i in self.input_data().split()]
        now = 0

        for i in range(n):
            if stairs[i] < now:
                print('No')
                exit(0)
            if stairs[i] > now:
                stairs[i] -= 1
                now = stairs[i]

        print('Yes')

solver = C(REL_PATH)
solver.exec_resolve()

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

    ans = True
    MAX = h[0]
    for i in range(n):
        if h[i] > MAX:
            MAX = h[i]
        elif h[i] < MAX - 1:
            ans = False
        else:
            continue
        
    print('Yes' if ans else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
count = 0

max_n = 0

for i in range(n):
    if max_n < a[i]:
        max_n = a[i]
    if max_n-a[i]>1:
        count += 1

if count >= 1:
    print("No")
else:
    print("Yes")

Solution (Python):
n = int(input())
hist = list(map(lambda x: int(x), input().split()))

min_val = 0
ans = True

for h in hist:
    if h-1 >= min_val:
        min_val = h - 1
    elif h >= min_val:
        min_val = h
    else:
        ans = False
        
if ans:
    print('Yes')
else:
    print('No')

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

tmp = -1
flag = True
for i in range(N-1,0,-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')

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

le=int(len(H))

a=0
for i in range(0,N):
    if a-1>H[i]:
        print("No")
        sys.exit()
    if H[i]>a:
        a=H[i]
print("Yes")

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
 
hmax = H[-1]
 
for h in reversed(H):
  if h <= hmax:
    hmax = h
    continue
  if h-1 <= hmax:
    hmax = h-1
    continue
  print('No')
  quit()

print('Yes')

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

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

flag = True

maxNum = 0

for i in range(len(nums)):
    maxNum = max(nums[i] - 1, maxNum)
    if nums[i] < maxNum:
        flag = False


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

Solution (Python):
from functools import reduce

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


ans, _ = reduce(
    lambda acc, h: (
        (
            'Yes' if acc[0] == 'Yes' and acc[1] <= h else
            'No'
        ),
        h if acc[1] >= h else
        h - 1
    ),
    H,
    ('Yes', 0)
)

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


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

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Solution (Python):
def getResult(HList, std) :
    for i in range(1, N) :
        if HList[i] > std :
            std = HList[i] - 1

        if HList[i] < std :
            return "No"
    return "Yes"


N = int(input())
HList = [int(i) for i in input().split(" ")]
std = HList[0]
print(getResult(HList, std))

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

    print('Yes')


if __name__ == "__main__":
    main()