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

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

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

next = 10**9
for i in range(N-1,0,-1):
  if H[i] <= next:
    next = H[i]
  elif H[i]-1 <= next:
    next = H[i]-1
  else:
    print("No")
    exit()
  
print("Yes")

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

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

print('Yes')

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

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

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

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

lowed = [True for i in range(n)]
fin = [False for i in range(n)]

if h_list == sorted(h_list):
    print("Yes")
else:
    while True:
        count = 0
        for i in range(n - 1):
            if h_list[i] > h_list[i+1] and lowed[i]:
                h_list[i] -= 1
                lowed[i] = False
                count += 1
        if count == 0 or lowed == fin:
            break
    if h_list == sorted(h_list):
        print("Yes")
    else:
        print("No")

Solution (Python):
n = input()
h = list(map(int,input().split()))
def ki(h):
    if h[0] > 1:
        h[0] = h[0] -1
    a=1
    for i in h[1:]:  
        if i < h[a-1] :  
            return("No")
        elif i != h[a-1]:  
            h[a] = h[a] - 1 
        a += 1
    return("Yes")
print(ki(h))

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

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

    elif H[i] >= H[i + 1]:
        continue

    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):

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

rev_H = H[::-1]

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

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

print("Yes")

Solution (Python):


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

rev_H = H[::-1]

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

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

print("Yes")

Solution (Python):


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

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

print("Yes")

Solution (Python):


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

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

print("Yes")

Solution (Python):



num = int(input())


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

def judge(num_list, num):
    if num == 1:
        return('Yes')

    decrease = False
    for i in range(0,len(num_list)):
        if i + 1 == num:  
            return('Yes')  

        if num_list[i] == num_list[i+1]:
            pass
        elif num_list[i] < num_list[i+1]:
            decrease = False
        elif num_list[i] - 1 <= num_list[i+1]:
            if decrease:
                return('No')
            else:
                decrease = True
        else:
            return('No')
        '''
        for j in range(i+1,len(num_list)):
          if num_list[i] -1 <= num_list[j]:
            if i+1 == num-1:
                return('Yes')
          else:
            return('No')
        '''


print(judge(num_list, num))

Solution (Python):

import sys
N = int(sys.stdin.readline().strip());
H = sys.stdin.readline().split();
H = [int(x) for x in H]

q = [0 for x in range(N)]

u = H[::-1]
q[0] = u[0]


flag = True

for i in range(1, N):
	
	if(u[i]>=q[i-1]+2):
		flag = False
		break
	
	if(u[i]==q[i-1]+1):
		
		q[i] = u[i]-1
	else:
		
		q[i] = u[i]

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

Solution (Python):

n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i-1] == h[i] +1:
        h[i-1] = h[i-1]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')

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

ans = "Yes"
for i in reversed(range(1, n)):
  if h[i]>=h[i-1]:
    continue
  elif h[i-1] - h[i] == 1:
    h[i-1] -= 1
  else:
    ans = "No"
    break

print(ans)

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

flag = True

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

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

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

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

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

ans = "Yes"

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

print(ans)

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

Solution (Python):
"""
WA出したやつ、例えば[1, 2, 2, 3, 3, 2]は4,5番目の3を2に減らせばYesになるが、
前から見ていって減少しているときだけ縮めるアルゴリズムでは[1, 2, 2, 3, 2, 2]となりNoになってしまう。
なので、後ろから見ていく。
"""
import sys

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

for i in range(len(H)-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()))

pre = -999
for i in range(N):
  if pre <= H[i]-1:
    pre = H[i]-1
  elif pre <= H[i]:
    pre = H[i]
  else:
    print("No")
    exit()
  
print("Yes")

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

pre = -999
for i in range(N):
  if pre <= H[i]-1:
    pre = H[i]-1
  elif pre <= H[i]:
    pre = H[i]
  else:
    print("No")
    exit()
  
print("Yes")

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

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

Solution (Python):


N = int(input())
HL = list(map(int, input().split()))
HR = HL[:]

for i in range(N-1):
    HL[i] = HL[i] - (1 if HL[i] > HL[i+1] else 0)
    HR[N-i-2] = HR[N-i-2] - (1 if HR[N-i-1] < HR[N-i-2] else 0)

resL = "Yes"
for i in range(N-1):
    if HL[i] > HL[i+1]:
        resL= "No"
        break

resR = "Yes"
for i in range(N-1):
    if HR[i] > HR[i+1]:
        resR = "No"
        break

print("Yes" if resL == "Yes" or resR == "Yes" else "No")

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

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

print ('Yes')

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, len(h)):
    if h[i] - 1 >= h[i - 1]:
        h [i] -= 1

ans = 1
for i in range(1, len(h)):
    if h[i] < h[i - 1]:
        ans = 0
        break

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

Solution (Python):
n = int(input())
h = [int(i) for i in input().split()]
flag = False
for i in range(n-1):
  sa = h[i] - h[i+1]
  
  if sa > 1:
    print("No")
    exit()
   
  if sa == True and flag:
    print("No")
    exit()
  
  if sa == 1:
    flag = True
    
  if sa < 0:
    flag = False

print("Yes")

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

flag = True

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

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

print('Yes')

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
HH = inpl()
HH[0] -= 1
for i in range(N-1):
    
    if HH[i+1]-HH[i] > 0:
        HH[i+1] -= 1
    elif HH[i+1]-HH[i] == 0:
        continue
    else:
        print('No')
        exit()

print('Yes')

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

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

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

print(answer)

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

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

print(answer)

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())
a = list(map(int, input().split()))
ok = True
a[0] -= 1
for i in range(1, n):
    if a[i - 1] < a[i]:
        a[i] -= 1
    if a[i - 1] > a[i]:
        ok = False

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

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

print('Yes')
exit(0)

Solution (Python):
N = int(input())
h_list = list(map(int, input().split()))
 
ans= "Yes"
 
tmp = h_list[-1]
for h in h_list[::-1]:
  tmp = min(h, tmp)
  
  if h >= tmp + 2:
    ans = "No"

print(ans)

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

prev = -999
for i in range(N):
  if prev <= hh[i]-1:
    prev = hh[i]-1
  elif prev <= hh[i]:
    prev = hh[i]
  else:
    print('No')
    exit(0)

print('Yes')
exit(0)

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):
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
l = ai()
m = [0 for _ in range(n)]
f = 'Yes'
for i in range(1,n+1):
    if i == 1:
        m[-1] = l[-1]
    else:
        if l[-i]-m[-i+1]>1:
            f = 'No'
        m[-i] = min(l[-i],m[-i+1])

print(f)

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

print("Yes")

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

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

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

ans = "Yes"

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

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

  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

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

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

if N > 1:
	a =n[0]

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

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

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

Solution (Python):


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

height = 10 ** 10
for i in range(N-1, -1, -1):
    if H[i] > height:
        if H[i] - 1 > height:
            print("No")
            exit()
        else:
            height = H[i] - 1
    else:
        height = H[i]

print("Yes")

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

flg = 0

if n ==1 :
    pass
elif n>=2:
    for i in range(n-1):
        
        if h[i]-1 == h[i+1]:
            h[i+1] = h[i+1]+1
        
        elif h[i] <= h[i+1]:
            pass
        else:
            flg = 1

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

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

def loop(H):
    tmp=0
    for h in H:
        if h<tmp:
            return("No")
        elif tmp <=h-1:
            tmp=h-1
        elif tmp<=h:
            tmp=h
    return "Yes"
print(loop(H))

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

for i in range(N-1,1,-1):
    H0=H[i]-H[i-1]
    if H0 <= -2:
        print("No")
        exit()
    elif H0 == -1:
        H[i-1] -= 1

    
print("Yes")

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

ans = 'Yes'
for i in range(N - 2, 0, -1):
  if h[i] > h[i + 1] + 1:
    ans = 'No'
    break
  elif h[i] == h[i + 1] + 1:
    h[i] -= 1

print(ans)

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

h = h[::-1]

for i in range(len(h)-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
        if not  h[i] == h[i+1]:
            print("No")
            exit()

print("Yes")

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

if N == 1:
    print("Yes")
else:
    for i in list(range(N)[::-1]):
        if i == 0:
            print("Yes")
            break

        if H[i] < H[i-1]:
            if H[i-1] - H[i] == 1:
                H[i-1] -= 1
            else:
                print("No")
                break

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

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

res = True
if n == 1:
    print('Yes')
else:
    for i in range(1,n):
        if stairs[i] - stairs[i-1] > 0:
            stairs[i] -= 1
        elif stairs[i] - stairs[i-1] < 0:
            res = False
            break
    if res:
        print('Yes')
    else:
        print('No')

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):
N = int(input())

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

maxlst = []
minlst = []
R = 10**10
L = 0
for i in range(N):
	L = max(X[i],L) 
	maxlst.append(L)
	R = min(X[-i-1],R)
	minlst.append(R)

minlst.reverse()
for i in range(N-1):
	if maxlst[i]-minlst[i+1] > 1:
		print("No")
		exit()
print("Yes")

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

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

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

m = h[-1]

for x in reversed(h):
    if x > m + 1:
        print('No')
        exit()
    elif x < m:
        m = x

print('Yes')

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

pre = 10**10
for h in Hs:
    
    if pre - h  >= 0:
        pre = h
    elif pre - h == -1:
        pre = h -1 
    else:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
import sys

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

n_str = str(n)
li_size = len(li)
max = li[0]
for i in range(li_size):
  if max == li[i]:
    continue
  elif max > li[i]:
    print("No")
    sys.exit()
  elif max < li[i]:
    max = li[i] - 1
print("Yes")

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

H = list(map(int, input().split()))
A = [0 for i in range(N)]

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

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

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

                                                                                                                                                                                                                                                                                
flag = True                                                                                                                                                                                                                                                                     
for i in reversed(range(1, N)):                                                                                                                                                                                                                                                 
    diff = h_list[i-1]- h_list[i]                                                                                                                                                                                                                                               

    if diff >= 2:                                                                                                                                                                                                                                                               
        flag = False                                                                                                                                                                                                                                                            
        break                                                                                                                                                                                                                                                                   
    elif diff == 1:                                                                                                                                                                                                                                                             
        h_list[i-1] -= 1                                                                                                                                                                                                                                                        
    else:                                                                                                                                                                                                                                                                       
        pass                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                
if flag:                                                                                                                                                                                                                                                                        
    print("Yes")                                                                                                                                                                                                                                                                
else:                                                                                                                                                                                                                                                                           
    print("No")

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

for i, h in enumerate(H):
    if i > 0 and H[i - 1] < h:
        H[i] -= 1

tmp = -1
for h in H:
    if h < tmp:
        print('No')
        exit()
    tmp = h
print('Yes')

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

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

ans = 0
tmp = 0
for i in range(N-1):
  if H[i]-1 > tmp:
    tmp = H[i]-1
  if H[i] > H[i+1]:
    H[i] = H[i]-1
    if H[i] > H[i+1]:
      ans = 1
  if tmp > H[i]:
    ans = 1
    
if ans == 1 :
  print("No")
else :
  print("Yes")

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

Solution (Python):

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

bef = H[0]
temp = [bef]
for i in H[1:]:
    if i != bef:
        temp.append(i)
    bef = i

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

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

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

curr = H[0] - 1 if H[0] > 0 else H[0]
success = True
for nxt in H[1:]:
  if nxt - curr >= 1:
    nxt -= 1
  if nxt >= curr:
    pass
  else:
    success = False
    break
  curr = nxt
    
if success:
  print('Yes')
else:
  print('No')

Solution (Python):
n_squares = int(raw_input(""))
height_squares = map(int, raw_input("").split(' '))

def check(n_squares, height_squares):
  if n_squares <= 1:
    return "Yes"
  for i in range(0, len(height_squares) - 1):
    if height_squares[i] > height_squares[i + 1]:
      return "No"
  return "Yes"
  
m = 0
for i in range(0, len(height_squares)):
  tmp = height_squares[i] - 1
  if tmp >= m:
    m = tmp
    height_squares[i] = tmp
print check(n_squares, height_squares)

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

if N == 1:
    print("Yes")
else:
    for i in range(1, N):
        if H[i-1] <= H[i]:
            continue
        elif H[i-1] == H[i]+1:
            H[i] += 1
        else:
            flag = False
            break

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

Solution (Python):
n = int(input())
h = map(int, input().split())
f = mx = 0
for hi in h:
    mx = max(mx, hi)
    if hi <= (mx-2): f = 1; break
print('YNeos'[f::2])

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
f, mx = 0, 0
for hi in h:
    if hi > mx: mx = hi
    if hi <= (mx-2): f = 1; break
print('YNeos'[f::2])

Solution (Python):
n = int(input())
h = list(map(lambda x: int(x), input().split()))
f, mx = 0, 0
for hi in h:
    if hi > mx: mx = hi
    if hi <= (mx-2): f = 1; break
print('YNeos'[f::2])

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

for x in range(N-1,0,-1):
    if A[x]-A[x-1]<0:
        A[x-1]=A[x-1]-1
for x in range(1,N):
    if A[x]-A[x-1]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')

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

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

    if H[i-1] < H[i]:
        H[i] -= 1

print("Yes")

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

for i in range(n + 1):
    if h[i] > h[i - 1]:
        max = h[i]
    if max - h[i] >= 2:
        flag = True

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

Solution (Python):
input()
mass = [int(s) for s in input().split()]
max = 0
result = ""

for n in mass:
  if max - n > 1:
    print("No")
    exit()
  if max < n:
    max = n

print("Yes")

Solution (Python):
input()
h=list(map(int,input().split()))
m=0
r=True
for i in h:
  r=i>=m-1
  if not(r):
    break
  m=max(m,i)
print("NYoe s"[r::2])

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, H: "List[int]"):
    
    
    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)
            exit()

    
    t = 0
    for i in range(N):
        if(H[i] < t):
            print(NO)
            exit()
    
    print(YES)

    return



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) ]  
    solve(N, H)

if __name__ == '__main__':
    main()

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

ans='Yes'
pre=-000
if N > 1:
    for i in range(0, len(H)):
        if (pre <= H[i] - 1):
            pre = H[i] - 1
            continue
        elif (pre <= H[i]):
            pre = H[i]
            continue
        else:
            ans = 'No'
            break

print(ans)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
f=0
m=0
for i in range(n-1):
    if a[i]>m:
        a[i]-=1
    if a[i]>a[i+1]:
        f=1
        break
    if a[i]>m:
        m=a[i]
if f==1:
    print("No")
else:
    print("Yes")

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

for i in range(1, n, 1):
    if nums[i] < nums[i - 1]:
        print("No")
        exit()

    if nums[i] > nums[i - 1]:
        nums[i] -= 1

print("Yes")

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

falg = 0

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

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