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

ans = 1
done = 0
h[0] = h[0] - 1

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

    if h[i-1] > h[i]:
        ans = 0
        done = 1
    if done:
        break


 

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

Solution (Python):
def resolve():
    n = int( input() )
    h = list(map(int,input().split()))
    if n==1:
        print('Yes')
        exit(0)
    right = h[-1]
    for left in h[-2::-1]:
        if(left>right+1):
            print('No')
            exit(0)
        if(left==right+1):
            left=left-1
        right=left
    print('Yes')


if __name__ == "__main__":
    resolve()

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


N = int(N)
H = [int(x) for x in H.split(" ")]
C = 0
R = 0
M = H[0]

while C < (N-1):
    if H[C] - H[C+1] > 1:
        R = 1
        C = N
    elif H[C] - H[C+1] == 1:
        if M > (H[C]-1):
            R = 1
            C = N
        else:
            M = max(M, H[C+1])
            C += 1
    else:
        C+=1

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

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

arr[0] -= 1

result = 'Yes'

for i in range(1, n):
    if(arr[i] >= arr[i-1] + 1):
        arr[i] -= 1
    elif(arr[i] < arr[i-1]):
        result = 'No'
        break

print(result)

Solution (Python):
import sys
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')

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

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

Solution (Python):

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

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

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

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

Solution (Python):
import numpy as np

N = int(input())
r = input().split()
H = np.array(r, dtype='int')[::-1]

out = 'Yes'

h = H[0]
for i in range(N):
  h_next = H[i]
  if h_next > h + 1:
    out = 'No'
    break
  elif h_next == h + 1:
    h_next -= 1
    h = h_next
  else:
    h = h_next

print(out)

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

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())
H = list(map(int, sys.stdin.readline().rstrip().split()))
for k in range(2,N+1):
    if H[-k] <= H[-k+1]:
        continue
    elif H[-k] == H[-k+1] + 1:
    	H[-k] -= 1
    else:
        print("No");exit()
print("Yes")

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

for i in range(N-1):
    if H[i] >= H[i+1] and (i==0 or H[i] != H[i-1]):
        H[i] -= 1

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

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

Solution (Python):
import sys

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

max_num = 0
for num in h:
    max_num = max(max_num, num-1)
    if num < max_num:
        print('No')
        sys.exit()

print('Yes')

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
if n == 1:
    print("Yes")
else:
    l1 = l[1:]+[0]
    d = [i-j for (i,j) in zip(l1, l)][:-1]
    t = [i for i in d if i <= -2]
    if len(t) >= 1:
        print("No")
    else:
        if -1 not in d or d.count(-1)==1:
            print("Yes")
        else:
            p = d.index(-1)
            d = d[p+1:]
            s = ''.join(map(str, d))
            spl = s.split("-1") 
            if "" in spl[:-1]:
                print("No")
            else:
                if spl[-1] == "":
                    spl = [s for s in spl if s != '']
                    y = [int(i) for i in spl]
                    if 0 not in y:
                        print("Yes")
                    else:
                        print("No")
                else:
                    y = [int(i) for i in spl]
                    if 0 in y[:-1]:
                        print("No")
                    else:
                        print("Yes")

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

flag=True
new=[]
new.append(li[0])

for i in range(1,len(li)):
  
  if li[i]>=li[i-1] :
    pass
  else :
    flag=False
    break
"""
if flag :
  print("Yes")
else :
  
   
  for i in range(0,len(li)-1):
    if li[i] ==li[i+1]+1 :
      li[i]=li[i]-1
    elif li[i]<=li[i+1] :
      pass
    else:
      flag=False
      break
""" 
if flag :
  print("Yes")
else:
  for i in range(n-1,0,-1):
    if li[i-1]>li[i] :
      li[i-1] -= 1
    
 
  flag=True
  for i in range(1,len(li)):
  
    if li[i]>=li[i-1] :
      pass
    else :
      flag=False
      break
  if flag :
    print("Yes")
  else :
    print("No")

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

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

max = 0
for i in range(N):
  if max < H[i]:
    max = H[i]
  if max - H[i] >= 2:
    print("No")
    exit(0)
print("Yes")

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

max = hList[0]
for i in range(n):
    if max < hList[i]:
        max = hList[i]
    if max - hList[i] >= 2:
        ans = 'No'

print(ans)

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

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

print("Yes")

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


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

print("Yes")

Solution (Python):
from sys import stdin
n = int(input())
a = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n-1):
  if a[n-1-i] < a[n-1-i-1] :
    a[n-1-i-1] -= 1 
  if a[n-1-i] < a[n-1-i-1] :
    
    print("No")
    exit()
  """
  if i > 0:
    if a[i] < a[i-1]:
      print("No")
      exit()
  """
        
print("Yes")

Solution (Python):

"""
Created on Fri Aug  9 21:30:56 2019

@author: Yamazaki Kenichi
"""

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

highest = 0

ans = 'Yes'
for i in range(N):
    if H[i] < highest - 1:
        ans = 'No'
    if H[i] > highest:
        highest = H[i]

print(ans)

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

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

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

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

Solution (Python):
while True:
    try:
        N = int(input())
        H = list(map(int, input().split()))
        for i in range(len(H)):
            if H[i] > 0 and(i == 0 or H[i] > H[i-1]):
                H[i] -= 1
            if i > 0 and H[i] < H[i-1]:
                print("No")
                break
        else:
            print("Yes")
    except EOFError:
        break

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

ans = "Yes"
m = 0
for i in range(n):
	if m - lis[i] > 1:
		ans = "No"
		break
	else:
		m = max(m,lis[i])
print(ans)

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

if n == 1:
    flag = 0
else:
    for i in range(n-1):
        idx = n-1-i
        if (H[idx-1] - H[idx]) == 1:
            H[idx-1] -= 1
        elif (H[idx-1] - H[idx]) > 1:
            flag = 1
            break

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

Solution (Python):
N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

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

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

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

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

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

Solution (Python):
def check(h):
    prev = h[0]
    for i, height in enumerate(h):
        if prev < height:
            h[i] -= 1
        elif prev > height:
            return False
        prev = h[i]
    return True

n = int(input())
h = list(map(int, input().split()))
print('Yes' if check(h) else 'No')

Solution (Python):
i = int(input())
s = list(map(int, input().split()))
m = 0
a = 'Yes'

for n in range(i):
    if s[n] < (m-1):
        a = 'No'
    m = max(s[n],m)

print(a)

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

prevNum = 10 ** 9 
isPossible = True

for i in reversed(range(len(sqrList))):
    nowNum = sqrList[i]
    if nowNum > prevNum:
        if nowNum != prevNum + 1:
            isPossible = False
            break
    else:
        prevNum = nowNum

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

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

a=0

if n==0:
    a=0
else:
    for i in range(n-1):
        if lis[n-i-2]>lis[n-i-1]:
            lis[n-i-2]-=1

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

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

Solution (Python):
n = int(input())
flag = True
ls = list(map(int, input().split()))
ls[0] -= 1

for i in range(n - 1):
    if ls[i] > ls[i + 1]:
        flag = False
        break
    elif ls[i] < ls[i + 1]:
        ls[i + 1] -= 1

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

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

possible = True

H = list(map(lambda x: int(x), input().split()))
H[0] -= 1

for i in range(N - 1):
	if H[i] > H[i + 1]:
		possible = False
		break
	elif H[i] < H[i + 1]:
		H[i + 1] -= 1

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

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

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

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

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

print('Yes')

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

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

if a == True:
    print('Yes')

Solution (Python):
N = int(input())
b_list = list(map(int,input().split()))
s = True
if (b_list[0] > 1):
  b_list[0] -= 1
for i in range(1,len(b_list)):
  if (b_list[i-1] < b_list[i]):
    b_list[i] -= 1
for i in range(len(b_list)-1):
  if (b_list[i] > b_list[i+1]):
    s = False
if (s):
  print('Yes')
else:
  print('No')

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

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

for i in range(len(H_list) - 1):
  if H_list[i] < H_list[i + 1]:
    H_list[i + 1] -= 1
  if H_list[i] > H_list[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,h in enumerate(H):
    if i == 0:
      H[i] = H[i] - 1
    else:
      if H[i-1] < H[i]:
        H[i] = H[i] - 1
      elif H[i-1] == H [i]:
        None
      else:
        print('No')
        break
  else:
    print('Yes')

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

flag = True
h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i] - 1:
    h_previous = H[i] - 1 
  elif h_previous <= H[i]:
    h_previous = H[i]
  else:
    flag = False
    break
    
  
if flag:
  print("Yes")
    
else:   
    
  print("No")

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

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

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

    ans="Yes"
    m=0

    for i in range(n):
        if(m>=h[i]+2):
            ans="No"
        else:
            m=max(m,h[i])
        if(ans=="No"):
            break
        
    print(ans)
    
main()

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

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

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

Solution (Python):
N = int(input())
H = input().split()
cnt = 0

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

if (cnt != 0):
    print("No")
else:
    print("Yes")

Solution (Python):
n_len = int(input())
n_list = [int(x) for x in input().split()]
flag = 0

n_border = 0

for ind in range(n_len - 1):
    n1 = n_list[ind]
    n2 = n_list[ind+1]
    if n1 - 1 > n_border:
        n_border = n1 - 1
    
    if (n1 <= n2) | (n1 - 1 <= n2) & (n_border <= n2):
        pass
    else:
        flag = 1
        break
        
if flag:
    print('No')
else:
    print('Yes')

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

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

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

flag=True
H.reverse()
temp = H[0]+1
for i in H:
    if(i>temp+1):
        flag=False
        break
    elif(i==temp+1):
        temp=i-1
    elif(i<=temp):
        temp=i;

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

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



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

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

a = "Yes"
m = 0

for i in range(n):
	if m - h[i] > 1:
		a ="No"
		break
	else:
		m = max(m,h[i])
print(a)

Solution (Python):


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

m = 0
ans = "Yes"
for i in range(N):
    if m - H[i] > 1:
        ans = "No"
        break
    m = max(m, H[i])

print(ans)

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

if N == 1:
    print("Yes")
elif N == 2:
    if num[0] - num[1] < 2:
        print("Yes")
    else:
        print("No")
else:
    flag = True
    for i in range(N - 2, 0, -1):
        diff = num[i] - num[i + 1]
        if diff <= 0:
            pass
        elif diff == 1:
            num[i] -= 1
        else:
            flag = False
            break
    print("Yes" if flag else "No")

Solution (Python):

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

Solution (Python):
n = input()
l = list(map(int, input().split()))
m = 0
a = "Yes"
for i in l:
    if i < m-1:
        a = "No"
        break
    m = max(m, i)
print(a)

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

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

flag = True
for i in reversed(range(1, n)):
    if H[i-1] <= H[i]:
        continue
    elif H[i-1] - H[i] == 1:
        H[i-1] -= 1
    else:
        flag = False

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

Solution (Python):
input()
h = list(map(int, input().split()))
m = 0
f = 1
for i in h:
    f &= i > m-2
    m = max(m, i)
print(["No", "Yes"][f])

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

Solution (Python):
n = int(input())
h = list(reversed(list(map(int, input().split()))))
ans = "Yes"
for i in range(n-1):
    m = h[i]-h[i+1]
    if m < -1:
        ans = "No"
    elif m == -1:
        h[i+1] -= 1
print(ans)

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

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)

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

max = 0
for i in range(n):
    if max < h[i]:
        max = h[i]
    if max - h[i] >= 2:
        print("No")
        exit()
print("Yes")

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

p = 0
ans = 'Yes'
for i in range(n-1):
    if h[i] < h[i+1]:
        p = 0
    elif h[i] == h[i+1] + 1 and p == 0:
        p = 1
    elif h[i] == h[i+1]:
        pass
    else:
        ans = 'No'
        break

print(ans)

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

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

ok = True
max_value = 1
for i in range(N-1):
    if max_value < boxes[i]:
        max_value = boxes[i]

    diff = boxes[i+1] - boxes[i]
    if diff >= 0:
        pass
    elif diff == -1:
        boxes[i] -= 1
        if max_value - 1 > boxes[i]:
            ok = False
    else:
        ok = False

    if not ok:
        break

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

Solution (Python):
N=int(input())
H=[int(h) for h in input().split()][::-1]
A="Yes"
for i in range(N-1):
    if H[i+1]-H[i] > 1:
        A="No"
        break;
    elif H[i+1]-H[i] == 1:
        H[i+1] -= 1
print(A)

Solution (Python):


trout_num = int(input())
height_list = [int(i) for i in input().split(" ")]
if trout_num == 1:
    print("Yes")
else:
    for i in range(0, trout_num - 1):
        heig_dif = height_list[i + 1] - height_list[i]
        if heig_dif != 0:
            if heig_dif >= 1:
                height_list[i + 1] -= 1
            else:
                print("No")
                break
    else:
        print("Yes")

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

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

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

Hn[0] -= 1
for i in range(1,len(Hn)):
	if Hn[i-1] <= Hn[i]-1:
		Hn[i] -=1
	elif Hn[i-1] == Hn[i]:
		pass
	elif Hn[i-1] > Hn[i]:
		print("No")
		exit()
else:
	print("Yes")

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

def checkCondition():
  for i in range(n-1):
    if numbers[i] > numbers[i+1]:
      if numbers[i] - numbers[i+1] > 1:
        return False
  for i in range(-1, -n, -1):
    sub = numbers[i-1] - numbers[i]
    if sub == 1:
      numbers[i-1] -= 1
    elif sub > 1:
      return False
  return True

if n == 1:
  print('Yes')
else:
  if checkCondition():
    print('Yes')
  else:
    print('No')

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

def checkCondition():
  for i in range(n-1):
    if numbers[i] > numbers[i+1] + 1:
      return False
  for i in range(-1, -n, -1):
    if numbers[i-1] - numbers[i] == 1:
      numbers[i-1] -= 1
    elif numbers[i-1] - numbers[i] > 1:
      return False
  return True

if n == 1:
  print('Yes')
else:
  if checkCondition():
    print('Yes')
  else:
    print('No')

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

base = H[0] - 1 if H[0] != 1 else 1 
for h in H[1:]:
    if h - base == 0 or h - base == 1:
        continue
    elif h - base > 1:
        base = h -1
    else:
        print("No")
        break
else:
    print("Yes")

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

def checkCondition():
  for i in range(n-1):
    if numbers[i] > numbers[i+1]:
      if numbers[i] - numbers[i+1] > 1:
        return False
  for i in range(-1, -n, -1):
    if numbers[i-1] - numbers[i] == 1:
      numbers[i-1] -= 1
    elif numbers[i-1] - numbers[i] > 1:
      return False
  return True

if n == 1:
  print('Yes')
else:
  if checkCondition():
    print('Yes')
  else:
    print('No')

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

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""

def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n = ip()
a = iprow()
cm = a[0]
for i in range(n):
    if a[i] > cm:
        cm = a[i]
    elif  a[i] < cm-1: j(0)
j(1)

Solution (Python):

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

before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)

Solution (Python):
import sys

N = int(sys.stdin.readline().rstrip())
HList = list(map(int,sys.stdin.readline().rstrip().split()))

hbefore=HList[0]
canDown=True
for i in range(1,N):
  if HList[i]-hbefore >0:
    canDown=True
  elif HList[i]-hbefore ==0:
    hbefore=HList[i]
    continue
  elif HList[i]-hbefore ==-1 and canDown:
    canDown=False    
  else:
    print("No")
    exit()
 
  hbefore=HList[i]
  
print("Yes")

Solution (Python):
from sys import exit, stdin

N = int(stdin.readline().rstrip())
H = [int(_) for _ in stdin.readline().rstrip().split()]
length = len(H)

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

x = 0
for i in H:
    if x > i:
        print('No')
        exit()
    x = max(x, i-1)
print("Yes")

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

for i in range(index):
  if(i == 0 and values[i] > 0):
    values[i] = values[i] -1
    continue
  if(values[i] > values[i-1]):
    values[i] = values[i] - 1

flag = "Yes"
for i in range(index):
  if(i == 0):
    continue
  if(values[i] < values[i-1]):
    flag = "No"

print(flag)

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

for i in range(index):
  if(i == 0):
    continue
  if(values[i] > values[i-1]):
    values[i] = values[i] - 1

flag = "Yes"
for i in range(index):
  if(i == 0):
    continue
  if(values[i] < values[i-1]):
    flag = "No"

print(flag)

Solution (Python):
a0=input()
a=input().split()
b=[int(x) for x in a]

for i in range(len(b)-1):
	if b[i]<=b[i+1]:
		pass
		if b[i-1]<=(b[i]-1) and (b[i]-1)<=b[i+1]:
			b[i]-=1
	elif b[i-1]<=(b[i]-1) and (b[i]-1)<=b[i+1]:
		b[i]-=1
	else:
		print("No")
		break
else:
	print("Yes")

Solution (Python):
import sys
n = int(input())
h = [int(i) for i in input().split(' ')]
for i in range(n-1):
    if h[i] <= h[i+1]:
        if h[i] <= h[i+1] -1:
            h[i+1] -= 1
    elif h[i] > h[i+1]-1:
        print('No')
        sys.exit()


print('Yes')

Solution (Python):
N=int(input())
H=list(map(int, input().split()))
Z=0
count=0
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
        Z=Z+1
        break
    if A == B:
        count=count+1
        if count >=2 and A < C:
            print('No')
            Z=Z+1
            break
        else:
            C=A
if Z == 0:
    print('Yes')

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

Solution (Python):
import sys

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

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

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

current = H[0]

for i, h in enumerate(H):
    if (current > h):
        if (current > h + 1):
            print('No')
            break
        else:
            current = h + 1
    else:
        current = h
else:
    print('Yes')

Solution (Python):
input()
vs=list(map(int, input().split(" ")))
k = 0
for i in range(0, len(vs)-1):
	if vs[i] - vs[i+1] >= 2:
		k = 100
		break
	if vs[i] - vs[i+1] == 1:
		k += 1
		if k >= 2:
			break
	elif vs[i+1] - vs[i] >= 1:
		k = 0
if k > 1:
	print("No")
else:
	print("Yes")

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

cnt=0
cnt=H[0]
for i,num in enumerate(H):
    if(cnt>num):
        if(cnt>num+1):
            print("No")
            cnt=-1
            break
    else:
        cnt=num

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