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

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

Solution (Python):
import sys

n=int(input())
h=list(map(int,input().split()))
max_h=0
for i in h:
    if i<max_h:
        print('No')
        sys.exit()
    max_h=max(max_h,i-1)
print('Yes')

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

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


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

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):
import sys

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

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

print('Yes')

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

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

max = l[0]
for i in range(n):
    if max - 1 > l[i]:
        print('No')
        sys.exit()
    elif l[i] > max:
        max = l[i]
print('Yes')

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

ans = 'Yes'
RH = list(reversed(H))
for i in range(N - 1):
    if RH[i] >= RH[i + 1]:
        continue
    if RH[i] == RH[i + 1] - 1:
        RH[i + 1] -= 1
        continue
    ans = 'No'

print(ans)

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

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

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

print('Yes')

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

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

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

Solution (Python):
import math
import copy
import sys


inputa = input().split()



a = int(inputa[0])








inputb = input().split()
inputbList = [int(n) for n in inputb]













flg = True

for i in range(a):
    if i == 0:
        inputbList[i] -= 1
    else:
        if inputbList[i] > inputbList[i-1]:
            inputbList[i] -= 1
        if inputbList[i] < inputbList[i-1]:
            flg = False
            break

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

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

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

Solution (Python):
n=int(input())
hs=list(map(int,input().split()))
judge=True
for i in range(n-1):
    if hs[i]<hs[i+1]:
        hs[i+1]-=1
    elif hs[i]>hs[i+1]:
        judge=False
        break


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

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

cur = H[0]
ans = 'Yes'

for i,h in enumerate(H[1:-1],1):
	if cur < h:
		if abs(cur-h) >= 2:
			ans = 'No'
			break
	else:
		cur = h

print(ans)

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

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

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

for i in b:
  if max < i:
    max = i
  elif max-1 > i:
    print('No')
    exit()
  
print('Yes')

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

print(ans)

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

ochinchin = True
for i in range(1, N):
    if H[i] < H[i-1]:
        H[i] += 1
        if H[i] < H[i-1]:
            ochinchin = False
            break
            

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

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

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

print("Yes")

Solution (Python):

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

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

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

pre_j = h_list[0]
f = 0
for j in h_list[1:]:
    if pre_j > j:
        f = 1
        break
    else:
        if pre_j < j:
            pre_j = j - 1

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

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

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

Solution (Python):
N = int(input())
lst = list(map(int, input().split()))
max = 0
cnt = 0
for j in lst:
    if max <= j-1:
        max = j-1
        cnt += 1
    elif max <= j:
        max = j
        cnt += 1
if cnt < N:
    print('No')
else:
    print('Yes')

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

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

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

l=list(map(int,input().split()))
l[0]-=1
Switch=True

for i in range(N-1):

    if l[i+1]==l[i]:
        pass
    elif l[i+1]>l[i]:
        l[i+1]-=1
    else:
        print("No")
        Switch=False
        break
    if i==N-2:
        print("Yes")
        Switch=False
    
if Switch:
    print("Yes")

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

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

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

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

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

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

ans = "Yes"
height = H[-1]
for i in range(2,N+1):
    if H[N-i] >= height+2:
        ans = "No"
        break
    elif H[N-i] >= height:
        continue
    else:
        height = H[N-i]

print(ans)

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

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

dhir={i:hi[n-1-i] for i in range(n)}

check=1
for i in range(n-1):
    if dhir[i] >= dhir[i+1]:
        continue
    elif dhir[i] == dhir[i+1]-1:
        dhir[i+1]-=1
        continue
    else:
        check=0

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

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

n = int(input())
l = list(map(int, input().split()))
l[0] -= 1
for i in range(1, n):
	if l[i] > l[i-1]:
		l[i] -= 1
if l == sorted(l):
	print("Yes")
else:
	print("No")

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

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

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

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

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

maxH = 0
res = 'Yes'
for h in height:
    maxH = max(maxH, h)
    if h < maxH-1:
        res = 'No'
        break
print(res)

Solution (Python):
def getlist():
    return list(map(int, input().split()))


N = int(input())
H = getlist()

j = "Yes"
val = H[0]
for i in range(1, N):
    if H[i] > val:
        val = H[i]
    else:
        if H[i] + 2 <= val:
            j = "No"
            break

print(j)

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

Solution (Python):
n = int(input())
h = [int(i) for i in input().split(' ')]
 
for i, e in enumerate(h[-2::-1]):
    if h[len(h) - i - 1] - e == -1:
        h[len(h) - i - 2] -= 1
    elif h[len(h) - i - 1] - e >= 0:
        continue
    else:
        print('No')
        exit(0)
 
print('Yes')

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

for i, e in enumerate(h[-2::-1]):
    if h[len(h) - i - 1] - e == -1:
        h[len(h) - i - 2] -= 1
    elif h[len(h) - i - 1] - e < -1:
        print('No')
        exit(0)

print('Yes')

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

H.insert(0, 1)
H.append(10 **10)

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

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

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
F = "Yes"
l = H[0]

for i in range(1, N):
	if l < H[i]:
		l = H[i]
	if l - 1 > H[i]:
		F = "No"
		break

print(F)

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

    heights = heights[::-1]
    res = True
    for i in range(N - 1):
        if heights[i] == heights[i + 1] - 1:
            heights[i + 1] -= 1
        elif heights[i] < heights[i + 1]:
            res = False
            break

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


if __name__ == '__main__':
    main()

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

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

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

for i in range(n-1, 0, -1):
    if h[i] >= h[i-1]:
        continue
    elif h[i-1]-h[i] == 1:
        h[i-1] -= 1
    else:
        print('No')
        break
else:
    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()))

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

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

if len(matchNums)==1:
    print("Yes")
    
else:
    check_array=[]
    check_array_all=[]
    
    for i in range(len(matchNums)-1):
        check_array.append((matchNums[i+1] - matchNums[i]))
    


    
    
    for i,val in enumerate(check_array):
        if val > 0:
            plus_flgs.append(i)
    
    
    plus_flgs.append(len(check_array))


    for i in range(len(plus_flgs)-1):
        check_array_all.append(sum(check_array[plus_flgs[i]+1: plus_flgs[i+1]]))

    
    if min(check_array_all)<-1:
        print("No")
    else:
        print("Yes")

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

ans="Yes"

for i in reversed(range(1, len(h))):
    if h[i] < h[i-1]:
        h[i-1]-=1
        if h[i] < h[i-1]:
            ans="No"
            break
print(ans)

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


nums=[int(x) for x in input().split()]
ans='Yes'
if(len(nums))<2:
    ans='Yes'
else:
    for i in range(len(nums)-1,0,-1):
        if nums[i-1] > nums[i]:
            nums[i-1] -=1
            if(nums[i-1] > nums[i]):
                ans='No'
                break
print(ans)

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

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

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

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

highest = 0
for h in H:
    if highest < h:
        highest = h
    if highest > h + 1:
        print('No')
        exit(0)
print('Yes')

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

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

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

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

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

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

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

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

for j in range(N - 1 , 0 , -1):
  if li[j] <= li[j - 1] - 2:
    out_count += 1
  elif li[j] == li[j - 1] - 1:
    li[j - 1] -= 1
if out_count == 0:
  print('Yes')
else:
  print('No')

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()]
h.reverse()
flag = True


def Back(x):
    x = x - 1
    return x


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

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

flag = 1
index = 0
bef = ""
while index < n:
    if bef == "":
        bef = listH[index]
    else:
        if bef <= listH[index]:
            bef = listH[index]
        elif bef == listH[index]+1:
            bef = listH[index]+1
        else:
            flag = 0
            break
    index+=1
if flag:
    print('Yes')
else:
    print('No')

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

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

for i in range(1, n):
  if hs[i-1] > hs[i]:
    print("No")
    break
else:
  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 = list(map(int,input().split(' ')))

for i in range(N-1,0,-1):
  if H[i-1] - H[i] >= 2:
    print('No')
    exit()
  elif  H[i-1] - H[i] == 1:
    H[i-1] -= 1
  else:
    pass
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]>1:
    print('No')
    sys.exit()
  if h[i]-h[i+1]==1:
    for j in range(i+1,n-1):
      if h[j+1]>h[j]:
        break
      if h[j+1]<h[j]:
        print('No')
        sys.exit()
    
print('Yes')

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
    else:
        pass
for i in range(n):
    if i == n-1:
        print('Yes')
    elif h[i] < h[i+1]:
        print('No')
        break
    else:
        pass

Solution (Python):
N = int(input())
cells = list(map(int, input().split()))
count = []
if N == 1:
    print('Yes')
else:
    for i in reversed(range(1, N)):
        if cells[i] <= cells[i - 1] - 2:
            print('No')
            break
        elif cells[i] == cells[i - 1] - 1:
            count.append('o')
            cells[i - 1] = cells[i - 1] - 1
        else:
            count.append('o')
    if len(count) == N - 1:
        print('Yes')

Solution (Python):

import sys

def main():
    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")
            return
    print("Yes")

if __name__ == '__main__':
    main()

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


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

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

ans = "Yes"
for i in range(N - 1):
    if lst_H[i] + 1 == lst_H[i + 1]:
        lst_H[i + 1] -= 1
    elif lst_H[i] >= lst_H[i + 1]:
        continue
    else:
        ans = "No"
        break
print(ans)

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


for i in reversed(range(len(towers))):
    if len(towers) <= i+1:
        continue

    if towers[i] > towers[i+1]:
        towers[i] -= 1



for i in range(1, len(towers)):
    if towers[i-1] > towers[i]:
        print('No')
        exit()

print('Yes')

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


for i in reversed(range(len(towers))):
    if len(towers) <= i+1:
        continue

    if towers[i] > towers[i+1]:
        towers[i] -= 1



for i in range(1, len(towers)):
    if towers[i-1] > towers[i]:
        print('No')
        exit()

print('Yes')

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

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

for n in reversed(range(1,N)):
    if H[n] >= H [n-1]:
        continue
    elif H[n] == H[n-1]-1:
        H[n-1] -= 1
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.append(1000000000)
m = 'Yes'
for i in range(0,n-1):
  if l[n-i-1] <= l[n-i]:
    continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)

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

for n in reversed(range(1,N)):
    if H[n] >= H [n-1]:
        continue
    elif H[n] == H[n-1]-1:
        H[n-1] -= 1
    else:
        print('No')
        exit()

print('Yes')

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

for i in reversed(range(1, len(h))):
  if h[i-1] > h[i]:
    h[i-1] = h[i-1] - 1


ans = 'Yes'
for i in reversed(range(1, len(h))):
  if h[i-1] > h[i]:
     ans = 'No'
print(ans)

Solution (Python):
s = input().split()
n=int(s[0])
s = input().split()
flag=0
for i in reversed(range(n-1)):
        if int(s[i])>int(s[i+1])+1:
                print('No')
                flag=1
                break
        if int(s[i])-int(s[i+1])==1:
                s[i]=int(s[i])-1
if flag<1:
        print('Yes')

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

Solution (Python):
n=int(input())
H=list(map(int,input().split()))
exit_flag=False
v=-float('inf')
for h in H:
    if v>h:
        if v!=h+1:
            print('No')
            exit()
        else:
            v=h+1
    else:
        v=h
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-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
if flag:
    print('Yes')

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

exit_flag = False
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:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')

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

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

nums[0] = max(0, nums[0]-1)
for i in range(1, n):
    if nums[i-1] < nums[i]:
        nums[i] -= 1
    if nums[i] < nums[i-1]:
        print('No')
        exit()

print('Yes')

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

if n==1:
  print("Yes")

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

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

a = 0
for b in map(int, input().split()):
  if b == a:
    a = b
  elif b > a:
    a = b - 1
  else:
    print('No')
    break
else:
  print('Yes')

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

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

flag = True
h[0] -= 1

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

        if diff <= -2:
            flag = False
            break
        elif diff == -1:
            h[i] -= 1

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

Solution (Python):
import sys

hs = list(map(int, sys.stdin.read().strip().splitlines()[1].split(" ")))
if len(hs) == 1:
  print("Yes")
  sys.exit(0)
if hs[0] > hs[1]:
  hs[0] -= 1

for i in range(1, len(hs)):
  pre = hs[i-1]
  diff = hs[i] - pre
  if diff >= 1:
    hs[i] -= 1
  elif diff < 0:
    print("No")
    sys.exit(0)
print("Yes")

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

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

Solution (Python):
if __name__ == '__main__':
  n = int(input())
  heights = map(int, input().split(' '))

  prev = -100
  answer = 'Yes'

  for height in heights:
    if (height >= prev + 1):
      height = height -1
    elif height == prev:
      height = height
    else:
      answer = 'No'
    prev = height
  
  print(answer)

Solution (Python):

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

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

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

print('Yes')

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

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

res = 'Yes'
for i in range(N-1):
    if H[i] > H[i+1]:
        res = 'No'

print(res)

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

print(ans)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
h_lst = [int(x) for x in stdin.readline().rstrip().split()][::-1]

if len(h_lst) < 1:
  print("Yes")
else:
  f = "Yes"
  prev = h_lst[0]
  for i in h_lst[1:]:
    if prev - i >= 0:
      prev = i
    elif prev - i == -1:
      prev = i - 1
    else:
      f = "No"
      break

print(f)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
H = list(map(int, input().split()))
max_n = H[0]; f = True;
for n in range(1, N):
    if max_n - H[n] >= 2:
        f = False
        break;
    elif max_n < H[n]:
        max_n = H[n]

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

Solution (Python):
_ = int(input())
h = [int(word) for word in input().split()]

prev_hi = h[0]
satisfies = False

for hi in h:
    if hi - 1 >= prev_hi:
        prev_hi = hi - 1
    elif hi >= prev_hi:
        prev_hi = hi
    else:
        break
else:
    satisfies = True

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

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

    M = max(M,h[i+1])
print("Yes")

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

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

    M = max(M,h[i+1])
print("Yes")

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

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

print(ans)

Solution (Python):
N = int(input())
pre = 0
ans = 'Yes'

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

for h in H:
    if pre < h:
        pre = h - 1
    elif pre == h:
        pre = h
    else:
        ans = 'No'
        break

print(ans)

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

ans = True
_max = 0
for i in range(N):
	_max=max(H[i], _max)
	if _max-H[i]>1:
		ans = False
		break
	if i==N-1:
		break

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

Solution (Python):
N = int(input())
pre = 0
ans = 'Yes'

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

for h in H:
    if pre < h:
        pre = h - 1
    elif pre == h:
        pre = h
    else:
        ans = 'No'
        break

print(ans)

Solution (Python):


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

def func(n, a):
    a[0] -= 1
    for i in range(1, n):
        diff = a[i] - a[i-1]
        if diff > 0:
            a[i] -= 1
        elif diff < 0:
            return "No"
    return "Yes"

print(func(n, a))

Solution (Python):
def C_BuildStairs():
    N = int(input())
    H = list(map(int, input().split()))
    ans = "Yes"
    for x in range(N - 1):
        if H[x] < H[x+1]:
            H[x+1] -= 1
        if H[x] > H[x + 1]:
            ans = "No"
            break
    print(ans)
    
if __name__ == "__main__":
    C_BuildStairs()

Solution (Python):

n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)