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(N, H):
    max_h = 0
    ret = True
    for h in H:
        if max_h-h >= 2:
            ret = False
            break
        max_h = max(max_h, h)
    print('Yes' if ret else 'No')

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

solve(N,H)

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

print('Yes')

Solution (Python):
n = int(input())
h = [int(i) for i in input().split()]
sub_flag = 0
for i in range(1,n):
    sub = h[i] - h[i-1] - sub_flag
    if sub < -1:
        print("No")
        break
    elif sub == -1:
        sub_flag = 1
    else:
        sub_flag = 0

else:
    print("Yes")

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

Solution (Python):
n = int(input())
h = [int(i) for i in input().split()]
for j in range(n-1):
  if h[j] - h[j+1] > 1:
    print("No")
    exit()
  elif h[j] == h[j+1] + 1:
    h[j+1] += 1
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]:
        h[i]-=1
    elif h[i]<h[i-1]:
        h[0]=-100
        break
if h[0]==-100:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  
from collections import defaultdict  
from heapq import heapify, heappush, heappop, heappushpop  
from bisect import bisect_left, bisect_right  
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7



def main():
    N = i2n()
    H = i2nn()
    n = 0
    for h in H:
        if n > h:
            print('No')
            return
        n = max(n, h-1)
    print('Yes')

main()

Solution (Python):


n = int(input())
h = list(map(int, input().split()))
p = h[0]
l = [p]
for i in range(1,n):
    c = h[i]
    if i == 1 and p - 1 == c:
        l[0] == c
    if p < c:
        c -= 1
    l.append(c)
    p = c
ans = 'Yes' if l == sorted(l) else 'No'
print(ans)

Solution (Python):
n=int(input())
h=[int(i) for i in input().split()]
j=h[-1]
for i in reversed(h):
  if i-j>1:
    print("No")
    exit()
  if i<j:
    j=i
print("Yes")

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

prev = -1
flag = True
for x in H:
  if x < prev:
    flag = False
    break
  if x == prev:
    continue
  prev = x - 1
  
print("Yes" if flag else "No")

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

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

Solution (Python):


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

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] and H[i]-H[i+1]==1:
    H[i] = H[i]-1
  elif H[i]<=H[i+1]:
    H[i] = H[i]
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
mah = 0
for i in range(N):
    if mah >= H[i] + 2:
        print("No")
        break
    elif mah >= H[i]:
        pass
    else:
        mah = H[i]
else:
    print("Yes")

Solution (Python):
num = int(input())
arr = list(map(int,input().split()))
count = 0
ans = 1
for i in range(num):
    if arr[i] > ans:
        ans = arr[i]
    
    elif arr[i] == ans:
        pass
    
    elif ans - arr[i] >=2:
        count +=1
        break

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

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

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

last = H[0] - 1
for i in range(N):
    h = H[i];
    if i==0:
        continue
    if h == last:
        last = h
    elif h >= last + 1:
        last = h - 1
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
while True:
    try:
        n = int(input())
        N = list(map(int, input().split()))
        N.reverse()

        mini = N[0]
        noAns = False
        for i in range(1, n):
            if N[i] <= mini:
                mini = N[i]
            elif N[i] == mini + 1:
                N[i] -= 1
            else:
                noAns = True
                break
        
        if noAns:
            print("No")
        else:
            print("Yes")
    except:
        break

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

for i in reversed(range(1,N)):
        if H[i-1] > H[i]:
                H[i-1] -= 1
        else:
                pass
        
ans = "Yes"

for i in (range(0,N-1)):
        if H[i+1] < H[i]:
                ans = "No"
                break
        else:
                pass

print(ans)

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] and H[i]-H[i+1]==1:
    H[i] = H[i]-1
  elif H[i]<=H[i+1]:
    H[i] = H[i]
  else:
    print("No")
    exit()
print("Yes")

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

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    
    x1 = H.pop()
    for i in range(N-1):
        x2 = H.pop()
        if x1 - x2 <= -2:
            print('No')
            break
        elif x1 > x2:
            x1 = x2
    else:
        print('Yes')

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

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

Solution (Python):
n=int(input())
li= list(int(i) for i in input().split())  
cnt=0
for i in range(1,n):
  if li[i]>li[i-1]:
    li[i]=li[i]-1
for j in range(0,n-1):
  if li[j]<=li[j+1]:
    cnt+=1
else:
  pass
if cnt==n-1:
  print('Yes')
else:
  print('No')

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

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

print('Yes')

Solution (Python):
n = int(input())
arr = list(map(int,input().split()))
ok = 'Yes'
arr[0] -= 1

for i in range(1,n):
    if arr[i] < arr[i-1]:
        ok = 'No'
        break
    elif arr[i] == arr[i-1]:
        continue
    else:
        arr[i] -= 1

print(ok)

Solution (Python):
n = int(input())
h = [int(x) for x in input().split(" ")]
 
for i in range(1, n):
  if h[-i]-h[-i-1] >= 0:
    continue  
  elif h[-i]-h[-i-1] == -1:
    h[-i-1] = h[-i-1] - 1
    continue
  elif h[-i]-h[-i-1] < -1:
    ans = "No"
    break
else:
  ans = "Yes"
  
print(ans)

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:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    h[0] -= 1
    for i in range(1, n):
        if h[i] > h[i-1]:
            h[i] -= 1
        if h[i] < h[i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    slove()

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

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

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

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

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


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

Solution (Python):
ans = 'Yes'
N = int(input())
H_list = input().split()
H_list = [int(H_list[i]) for i in range(N)]

if N == 1:
    print(ans)
else: 
    first_H = H_list[0]
    second_H = H_list[1]
    if first_H - second_H >= 2:
        ans = 'No'
        print(ans)
    else:
        first_H -= 1
        for i in range(2, N):
            if second_H - H_list[i] >= 2:
                ans = 'No'
                break
            elif second_H - H_list[i] == 1:
                if first_H >= second_H:
                    ans = 'No'
                    break
                else:
                    second_H -= 1
            elif first_H < second_H:
                second_H -= 1
            first_H = second_H
            second_H = H_list[i]
        print(ans)

Solution (Python):
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1

def is_stairs(h):
	for i in range(n - 1):
		if h[i + 1] > h[i]:
			h[i + 1] -= 1
		elif h[i + 1] < h[i]:
			return False
	return True
	
print('Yes' if is_stairs(h) else 'No')

Solution (Python):
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
  elif num_list[i] - num_list[i+1] >= 1:
    num_list[i+1] += 1
    
print(answer)

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

if len(l) == 1:
  print("Yes")
  quit()

a=l[-1]

for i in range(n-1):
  b = l[-2-i]
  if b - a  > 1:
    print("No")
    quit()
  if b - a == 1:
    b = b-1
  a = b
print("Yes")

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 = [int(x) for x in input().split()]
tmp = h[n-1]
for i in h[::-1]:
    if i <= tmp:
        tmp = i
    elif i-1 <= tmp:
        tmp = i-1
    else:
        print('No')
        exit()
print('Yes')

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

while h != []:
    ri = h.pop()
    if h == []:
        print('Yes')
        break
    v = h[len(h)-1] - ri
    if v >= 2:
        print('No')
        break
    elif v == 1:
        h[len(h)-1] -= 1
        if h[len(h)-1] < 0:
            print('No')
            break

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
n = int(input())

L = np.array(list(map(int, input().split())))

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

if np.all(L ==sorted(L)):
    print('Yes')
else:
    print('No')

Solution (Python):

N=int(input())
H=list(map(int, input().split()))
t=True
M=H[0]
for i in range(1,N):
    if M<H[i]:
        M=H[i]
    if M>H[i]+1:
        print("No")
        t=False
        break
if t:
    print("Yes")

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

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

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    for i in range(2, len(h)):
        if h[i-1] - h[i] > 1:
            return('No')
        h[i] = max(h[i-1],h[i])
    return('Yes')
print(is_stairs(h))

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

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

for i in range(N-1):


  if A[i+1] - A[i] <= -2:
    print('No')
    exit()
  elif A[i+1] - A[i] == -1:
    A[i+1] += 1
print('Yes')

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

is_break = False
for i in range(N - 1):
    j = N - i - 1
    if H[j - 1] > H[j]:
        H[j - 1] -= 1
    if H[j - 1] > H[j]:
        is_break = True

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

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

is_trimmed = [False] * N
max_v = 0
max_ids = []
succeed = True
for i in range(N):
    diff = max_v - H[i]
    if diff > 1:
        print('No')
        succeed = False
        exit(0)
    elif diff == 1:
        for j in max_ids:
            if is_trimmed[j]:
                print('No')
                succeed = False
                exit(0)
            is_trimmed[j] = True
        max_ids.append(i)
        max_v -= 1
    elif diff == 0:
        max_ids.append(i)
    elif diff < 0:
        max_v = max(max_v, H[i])
        max_ids = [i]
    

if succeed:
    print('Yes')

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

H_shifted = [0 for i in range(N)]

h_n_1 = 0
is_break = False
for i, h_i in enumerate(H):
    if h_n_1 > h_i:
        if H_shifted[i - 1] == 0:
            h_n_1 -= 1
        if h_n_1 > h_i:
            is_break = True
            break
        else:
            
            H_shifted[i] = 1
    if h_n_1 == h_i:
        
        H_shifted[i] = 1
    if h_n_1 < h_i:
        
        H_shifted[i] = 1
        h_n_1 = h_i - 1
    else:
        h_n_1 = h_i


if is_break:
    print('No')
else:
    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] = H[i+1]-1
        continue
    
    elif(H[i] == H[i+1]):
        continue
    
    
        
        
    
    
    

for j in range(N-1):
    if(H[j]>H[j+1]):
        print('No')
        sys.exit()
print("Yes")

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

ans = True
for i in range(1, len(h_list) ):
    if h_list[-i] - h_list[-i-1] >= 0:
        continue
    elif h_list[-i] - h_list[-i-1] == -1:
        h_list[-i-1] -= 1
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):

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

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

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

print('Yes')

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


for i in range(a - 1):
    
    if b[i + 1] - b[i] >= 0:
        if b[i + 1] - b[i] >= 1:
            b[i + 1] -= 1
    else:
        print('No')
        exit()

print('Yes')

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

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

max_height = 0
for h1, h2 in zip(H[:-1], H[1:]):
  max_height = max(max_height, h1-1)
  if max_height > h2:
    print("No")
    break
else:
  print("Yes")

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

t = 10 ** 9 + 1

res = "Yes"

for h in  lh:
	if h <= t:
		t = h
	elif h - 1 <= t:
		t = h - 1
	else:
		res = "No"
		break

print(res)

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

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

tmp = h.pop(0)

ans = "Yes"
for  i in h:
    if tmp > i:
        tmp = i
    elif tmp < i:
        if tmp < i-1:
            ans = "No"
        elif tmp == i-1:
            tmp = i-1

print(ans)

Solution (Python):
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

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

for i in reversed(range(1,N)):
    if hs[i] >= hs[i-1]:
        continue
    elif hs[i]  == hs[i-1] - 1:
        hs[i-1] -= 1
    else:
        print('No')
        sys.exit()


print('Yes')

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    h[0] -= 1
    for i in range(1, n):
        if h[i] > h[i-1]:
            h[i] -= 1
        if h[i] < h[i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()

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

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

res = len(H) <= 1
for i in range(len(H) - 1, 0, -1):
    right = H[i]
    left = H[i - 1]

    if left - right > 1:
        break

    if left - right == 1:
        H[i - 1] = left - 1

    if i == 1:
        res = True

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

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

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

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

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

i = 0

while True:
    if i == n-1:
        print('Yes')
        break
    if h[i] <= h[i+1]:
        if i == 0 or h[i-1] < h[i]:
            h[i] -= 1
        i += 1
    elif h[i] == h[i+1]+1 and (i==0 or h[i-1] < h[i]):
        h[i] -= 1
        i += 1
    else:
        print('No')
        break

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

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

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
ma = 0
for i in range(n):
    if ma < h[i]:
        ma = h[i]
    elif ma > h[i] + 1:
        print('No')
        quit()
print('Yes')

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]:
    H[i+1] = H[i+1] + 1
  if H[i] <= H[i+1]:
    c += 1
if c == N-1:
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
H = [int(x) for x in input().split()]
C = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i+1]=H[i+1]+1
  if H[i] <= H[i+1]:
    C += 1
if C == N-1:
  print("Yes")
else:
  print("No")

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

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

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

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

Solution (Python):
import sys

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

for i in h:
    height = max(height, i)
    if i < height - 1:
        print("No")
        sys.exit()

print("Yes")

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

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

Solution (Python):
import sys


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
    if h[i - 1] > h[i]:
        print('No')
        sys.exit()
print('Yes')

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

H = list(reversed(H)) 
ans='Yes'
if N==1:
    ans='Yes'
else:         
    for i in range(1, N):
        if H[i] - H[i-1] >= 2: 
            ans='No'
            break   
        elif H[i] - H[i-1] == 1: 
            H[i] -= 1
print(ans)

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

prev = 0
for v in a:
    if v > prev:
        v -= 1
    if v < prev:
        print("No")
        break
    prev = v
else:
    print("Yes")

Solution (Python):
n=int(input())
h_list=[int(s) for s in input().split()]

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

left=h_list[0]
for i in range(1,n):
    right=h_list[i]

    if left<right:
        left=right-1
        continue
    if left==right:
        continue
    print('No')
    exit()


print('Yes')

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

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

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

ok = True
threshold = hs[0] - 1
for i in range(1, n):
    if hs[i] < threshold:
        ok = False
        break
    threshold = max(threshold, hs[i] - 1)
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
H = [int(x) for x in input().split()][::-1]
for i in range(1, N):
    d = H[i] - H[i - 1]
    if d >= 2:
        print("No")
        exit()
    elif d == 1:
        H[i] -= 1
print("Yes")

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

Solution (Python):
n=int(input())
h=list(map(int,input().split()))
tmp=h[0]
for i in range(1,n):
  if tmp>h[i]:
    print("No")
    exit()
  else:
    tmp=max(tmp,h[i]-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] > 0:
        H[i] -= 1

flag = True
now = H[0]
for i in range(1, N):
    if now > H[i]:
        flag = False
        break
    else:
        now = H[i]

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

Solution (Python):
n=int(input())
h=[int(i) for i in input().split()]
for i in range(n-1,0,-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 = str(input())
H = list(map(str, input().split()))
for i in range(len(H)-1):
  if int(H[i]) > int(H[i+1])+1:
    print('No')
    sys.exit()
  if int(H[i]) == int(H[i+1])+1:
    H[i+1] = int(H[i+1])+1
print('Yes')

Solution (Python):
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()
flag = True

for i in range(1,len(h)):
    if (h[i-1] < h[i]):
        if (h[i] - h[i-1] <= 1):
            h[i] -= 1
        else:
            flag = False
            break

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

Solution (Python):


import sys
n = int(input())
lst=list(map(int,input().split()))

differences=[]
for i in range(1,n):
    if lst[i]-lst[i-1]==0:
        continue
    elif lst[i]-lst[i-1]<=-2:
        print("No")
        sys.exit()
    else:differences.append(lst[i]-lst[i-1])


if len(differences)>=2:
    for i in range(len(differences)-1):
        if differences[i]==-1 and differences[i+1]==-1:
            print("No")
            sys.exit()
 
 
print("Yes")

Solution (Python):
import sys
n = int(input())
lst=list(map(int,input().split()))
lst.append(10**9+1)

count = 0
for i in range(n):
 
    if lst[i+1]-lst[i]==-1:
        if count==0:
            count=-1
            continue
        else:
            print("No")
            sys.exit()
    elif lst[i]==lst[i+1]:
        continue
        
    elif lst[i]<lst[i+1]:
        count = 0
        continue
    
    else:
        print("No")
        sys.exit()
        


print("Yes")

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

for i in range(len(h)-1):
    down = False
    
    if h[i] > h[i+1]:
        if h[i] - h[i+1] > 1:
            ans = False
            break
        else:
            if h[i]-1 >= minv:
                h[i] -= 1
                minv = h[i]
                down = True
            else:
                ans = False
                break
    if not down and  i!=0 and h[i-1] < h[i]:
        h[i] -= 1
        minv = h[i]


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

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



temp=r[0]
flag=0
for item in r:
  if temp>=item:
    temp=item
  elif temp>=item-1:
    temp=item-1
  else:
    flag=1
    break
    
print("Yes" if flag==0 else "No")

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

Solution (Python):
import sys

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

n = L[0]
while True:
    if len(L) <= 0:
        break

    if L[0] - n < -1:
        print("No")
        sys.exit()

    n = max(n, L[0])
    L.pop(0)

print("Yes")

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

def solve(arr, n):
	arr[0] -= 1
	for i in range(1, n):
		left = arr[i] - arr[i-1]
		if left < 0:
			return False
		if left != 0: arr[i] -= 1
	return True

print("Yes" if solve(arr, n) else "No")

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
_max=0
for _ in H:
    if _max>_:
        print("No")
        exit()
    _max=max(_max, _-1)
print("Yes")

Solution (Python):
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(input())

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

    ans = 'Yes'

    for x in reversed(range(1, len(nums))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

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

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(input())

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

    ans = 'Yes'

    for x in reversed(range(1, len(nums))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

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

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()

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

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

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


ans = "Yes"
ma = -1
for i in range(n):
    if (ma < List[i]):
            ma = List[i] - 1
    elif (ma == List[i]):
        ma = List[i]
    else:
        ans = "No"
        break



print(ans)