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())
nums = list(map(int,input().split()))
nums = nums[::-1]
judge = "Yes"

for i in range(N-1):
  dev = nums[i+1] - nums[i]
  if dev > 1:
    judge =  "No"
    break
  elif dev == 1:
    nums[i+1] = nums[i+1] - 1
  else:
    continue
    
print(judge)

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

print('Yes')

Solution (Python):
n=int(input())
p=input().rstrip().split(' ')
l=[]
for i in range(0,len(p)):
    if i==0:
        p[i]=int(p[i])-1;
        l.append(int(p[i]))
    else:
        if int(p[i]) > int(p[i-1]):
            p[i] = int(p[i])-1;
            l.append(int(p[i]))
        else:
            l.append(int(p[i]))

l.sort(key=int)
for i in range(0,len(l)):
    if int(l[i])!=int(p[i]):
        print("No")
        break;
else:
    print("Yes")

Solution (Python):




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

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
min_ = int(10**9 + 1)

for i in H[::-1]:
    if i <= min_:
        min_ = i
    elif i == min_ + 1:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):

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

stop_flg = 0
h[0] = h[0]-1
for i in range(N-1):
    if stop_flg == 0:
        if h[i] <= h[i+1]-1:
            h[i+1] = h[i+1]-1
        elif h[i] == h[i+1]:
            continue
        else:
            stop_flg = 1

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

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

print('Yes')

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


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

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

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

Solution (Python):
import sys
N = int(input())
H = input().split()
S = 0
for i in range(N):
  if int(H[i]) > S:
    S = int(H[i])
  elif S - int(H[i]) >= 2:
    print('No')
    exit()
print('Yes')

Solution (Python):
_,h=open(0)
m=f=0
for h in h.split():h=int(h);f|=m-h>1;m=max(m,h)
print('YNeos'[f::2])

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

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


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

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

Solution (Python):
import sys

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

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

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

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

answer = 'Yes'

pre = 0
for i in range(n):
    if pre <= h[i]-1:
        pre = h[i]-1
    elif pre <= h[i]:
        pre = h[i]
    else:
        answer = 'No'
        break

print(answer)

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

def fun(lst):
    if len(lst) == 1:
        return "Yes"
    for i in reversed(range(1,len(lst))):
        
        if lst[i-1] - lst[i] == 1:
            lst[i-1] = lst[i-1]-1
        if lst[i-1] <= lst[i]:
            pass
        else:
            return "No"
    return "Yes"

print(fun(H))

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

pre = H[0]
for h in H[1:]:
    if h < pre:
        print("No")
        break
    elif h > pre:
        pre = h - 1
else:
    print("Yes")

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
answer='Yes'
for i in range(N-1):
    left=H[N-2-i]
    right=H[N-1-i]
    if left<=right and answer=='Yes':
        answer='Yes'
    elif left==right+1 and answer=='Yes':
        H[N-2-i]-=1
    else:
        answer='No'
print(answer)

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


def main():
    h[0] -= 1
    print("Yes" if detect() else "No")


def detect():
    for i in range(1, n):
        if h[i] > h[i-1]:
            h[i] -= 1
        elif h[i] < h[i-1]:
            return False

    return True


main()

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())
H = [int(x) for x in stdin.readline().rstrip().split()]


for i in range(N-2, -1, -1):
    diff = H[i] - H[i+1]

    if diff > 1:
        print("No")
        exit()

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


print("Yes")

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

if N == 1:
    print("Yes")
else:
    for ri in reversed(range(1, N)):
        if his[ri] == his[ri - 1]:
            continue
        elif his[ri - 1] - his[ri] == 1:
            his[ri - 1] -= 1
        elif his[ri - 1] - his[ri] > 1:
            print("No")
            exit()
    print("Yes")

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
answer='Yes'
for i in range(N-1):
    left=H[N-2-i]
    right=H[N-1-i]
    if left<=right and answer=='Yes':
        answer='Yes'
    elif left==right+1 and answer=='Yes':
        H[N-2-i]-=1
    else:
        answer='No'
print(answer)

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

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

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

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

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
memo=H[-1]
for i in range(N-1):
    h=H[N-2-i]
    if h<=memo:
        memo=h
    elif h==memo+1:
        pass
    else:
        print("No")
        exit()
print("Yes")

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

flag = True
fff = -1
for i in he:
  if i < fff:
    flag = False
    break
  if i == fff:
    continue
  fff = i - 1
if flag:
  print('Yes')
else:
  print('No')

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

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

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

invh = h[::-1]
diff = 0

for i in range(n-1):
    if invh[i+1] - invh[i] >= 2:
        print('No')
        exit()
    elif invh[i+1] - invh[i] == 1:
        diff += 1
        if diff > 1:
            print('No')
            exit()
    elif invh[i+1] - invh[i] < 0:
        diff = 0
print('Yes')

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

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

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

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

oH, minH = [], H[-1]
for i in range(N):
    minH = min(minH, H[-(i + 1)])
    oH.append(H[-(i + 1)] - minH)

print("Yes" if max(oH) <= 1 else "No")

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    hl = [0] + list(map(int, input().split()))

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

    print("Yes")

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

if N == 1:
    flag = 1
else:
    for i in range(N-2,-1,-1):
        if H[i] > H[i+1]:
            H[i] -= 1
    for i in range(N-1):
        if H[i] > H[i+1]:
            flag = 0

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

Solution (Python):
from sys import stdin
def ii(): return int(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def li(): return list(mi())
n=ii()-2
a=li()
for i in range(n, -1, -1):
    if a[i]>a[i+1]:
        a[i]-=1
        if a[i]>a[i+1]:
            print('No')
            exit()
print('Yes')

Solution (Python):
def c_build_stairs(N, H):
    max_current = 0
    for h in H:
        max_current = max(max_current, h)
        if h < max_current - 1:
            return 'No'
    return 'Yes'

N = int(input())
H = [int(i) for i in input().split()]
print(c_build_stairs(N, H))

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
flag = True
min_ = int(10**9 + 1)

for i in H[::-1]:
    if i <= min_:
        min_ = i
    elif i == min_ + 1:
        pass
    else:
        flag = False

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

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

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

flag = "Yes"
cnt = 0
if (N > 1):
  for i in range(len(lst) - 1):
    if (lst[i+1] - lst[i] < 0):
      cnt += 1
    elif (lst[i+1] - lst[i] > 0):
      cnt = 0
      
    if (cnt > 1 or lst[i+1] - lst[i] < -1):
      flag = "No"

print(flag)

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())) + [10**10+1]
Min = min(h)
for i in range(n):
    if h[-i-1] < h[-i-2]:
        h[-i-2] -=1
for i in range(n):
    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 reversed(range(1,n)):
  if h[i-1] - h[i] == 1:
    h[i-1] -= 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(1, N)):
  if H[i] < H[i-1]:
    if H[i] == H[i-1] - 1:
      H[i-1] -= 1      
    else:
      print("No")
      exit()
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()))

for i in range(N):

    if (i == 0) and H[i] > 0:
        H[i] = H[i] - 1

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

            print('No')
            exit(0)

        elif H[i] - H[i-1] >= 1:
            H[i] = H[i] - 1

print('Yes')

Solution (Python):

n = int(input())

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

f = 0

a=True

for i in range(n-1):
    if tan[i] < tan[i+1] :
        f -= 1
    else :
        f += (tan[i]-tan[i+1])

    if f < 0 :
        f=0
    elif f >= 2 :
        print("No")
        exit()
    else :
        pass

if a :
    print("Yes")

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

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

flag = False
ok = True
pos = 10**9+7

for i in range(N-1,-1,-1):
    pre = l[i]
    if pos>=pre:
        pass
    else:
        if (pre - pos)==1:
            pre -= 1
        else:
            ok = False
            break
    pos = pre
if ok:
    print('Yes')
else:
    print('No')

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

Solution (Python):
N = int(input())
H_list = [int(x) for x in input().split()]
result = None
elem_max = H_list[0]
for i in range(1, N):
  if H_list[i] > elem_max:
    elem_max = H_list[i]
  else:
    if elem_max - H_list[i] > 1:
      print('No')
      result = 'No'
      break
if result is None:
	print('Yes')

Solution (Python):
def c_build_stairs(N, H):
    for i in range(N - 1, 0, -1):
        if H[i - 1] - H[i] >= 2:
            return 'No'
        elif H[i - 1] - H[i] == 1:
            H[i - 1] -= 1
    return 'Yes'

N = int(input())
H = [int(i) for i in input().split()]
print(c_build_stairs(N, H))

Solution (Python):

def main():
    N = int(input())
    H = list(map(int,input().split()))
    H.reverse()
    for i in range(N):
        if i != N-1:
            if H[i]>=H[i+1]:
                continue
            if (H[i+1]-H[i])==1:
                H[i+1]=H[i+1]-1
            else:
                print('No')
                return
    if H[N-1]<=H[N-2] or (H[N-1]-H[N-2]==1):
        print('Yes')
        return
    else:
        print('No')
        return

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
H.reverse()
cnt = 0
for i in range(N-1):
  if H[i+1]-H[i]==1:
    H[i+1] = H[i+1]-1
  elif H[i+1]-H[i]>1:
    cnt = 1
    break
if cnt == 0:
  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] > 1:
        print("No")
        quit()

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

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

now_h = H[0]
e = 0
for h in H:
    if h - now_h == -1:
        if e > h:
            print('No')
            exit()
        else:
            e = h
            now_h -= 1
    elif h - now_h < -1:
        print('No')
        exit()
    now_h = h

print('Yes')

Solution (Python):
from sys import stdin, exit

N = int(stdin.readline().rstrip())
H = [int(x) for x in stdin.readline().rstrip().split()]
drop = 0

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

if N == 2:
    if H[0] - H[1] > 1:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

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

Solution (Python):
n = int(input())
h = [int(_) for _ in input().split()]
prev = 0
dec = False
once = False
big = 0
for i in range(1, n):
    if h[prev] - h[i] >= 2:
        print('No')
        dec = True
        break
    elif h[prev] > h[i] and once == False:
        once = True
        big = h[prev]
    elif h[prev] > h[i] and once:
        if h[prev] < big:
            print('No')
            dec = True
            break
        else:
            big = h[prev]
    prev += 1
    
if not dec:
    print('Yes')

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
l = []
for i in range(N-1):
    if a[i+1]-a[i] != 0:
        l.append(a[i+1]-a[i])

if any(i<=-2 for i in l):
    print("No")
    exit()



for i in range(len(l)-1):
    if l[i] == -1 and l[i+1] == -1:
        print("No")
        exit()
print("Yes")

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

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

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

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

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

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

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

Solution (Python):
import numpy as np

N = int(input())
H = np.array(list(map(int, input().split())))
H[0] -= 1
for i in range(0, N - 1):
    diff = H[i + 1] - H[i]
    if diff >= 1:
        H[i + 1] -= 1
    elif diff < 0:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
h = list(map(int,input().split())) + [10**10+1]
MAX = h[0]
for i in h:
    MAX = max(MAX, i)
    if MAX-1>i:
        print('No')
        exit()
print('Yes')

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

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

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

print("Yes")

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

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

    else:
        h_list[i - 1] -= 1

        if h_list[i] >= h_list[i-1]:
            continue
        else:
            ans = False
            break

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

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

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

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

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

Solution (Python):
import math
N = int(input())
Hs = [int(x) for x in input().split()]
current = Hs[0]-1
for H in Hs:
  if H < current:
    print('No')
    exit()    
  if H - current >= 1:
    current = H-1
  elif H == current:
    pass
print('Yes')

Solution (Python):

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

ans = 'Yes'
diff = 0

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

	if diff >= 1:
		H[i + 1] -= 1
	elif diff < 0:
		ans = 'No'

print(ans)

Solution (Python):
_,h=open(0)
m=f=0
for h in h.split():h=int(h);f|=m-h>1;m=max(m,h)
print('YNeos'[f::2])

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

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

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

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

ans = 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:
    ans = False
    break
  elif h[i-1] <= h[i]:
    pass
 
if ans == True:
  print("Yes")
else:
  print("No")

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

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

h[0] -= 1

if max(h) - min(h) == 1:
    print('Yes')
    exit()

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

for i in range(1, len(h)):
    if 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')
  exit()
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
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
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())
blocks=[int(i) for i in input().split()]

pre = blocks[-1]
no_flag = 0
cannot_down = 0
for this_block in reversed(blocks):
    if (this_block - pre) > 1:
        no_flag = 1
        break
    elif (this_block - pre) == 1:
        pre = (this_block - 1)
    else:
        pre = this_block
if no_flag:
    print("No")
else:
    print("Yes")

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

h = input().split()
H = [int(i) for i in h]
for i in reversed(range(N-1)):
    if H[i] > H[i+1]:
        H[i] -= 1
is_yes = True
for i in range(N-1):
    if H[i] > H[i+1]:
        is_yes = False
        break
if is_yes:
    print("Yes")
else:
    print("No")

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

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

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

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

flag = True
for i in range(1,len(H)):
	if H[i-1] > H[i]:
		if H[i-1]-1 == H[i]:
			H[i]+=1
		else:
			flag = False
			break

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

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

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

Solution (Python):


def main(N, H):
    ans = 'Yes'

    min_val = H[0] -1
    for i in range(1, N):
        if min_val <= H[i] -1:
            min_val = H[i] -1
        elif min_val <= H[i]:
            min_val = H[i]
        else:
            ans = 'No'
            break
    return ans

if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))

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

min = 0
for i in b:
    if min == i:
        continue
    if min > i:
        print("No")
        exit()
    if min < i :
        min = i-1



print("Yes")

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

h = []
h.append(h_org[0])

for i in range(1,n):
    if h_org[i-1] != h_org[i]:
        h.append(h_org[i])

if n == 1:
    print("Yes")
    exit()
elif n == 2:
    if h[0] <= h[1]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

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

    if h[i] <= h[i+1] and h[i-1] <= h[i]:
        pass
    elif h[i] - h[i+1] == 1 and h[i] - h[i-1] >= 1:
        pass
    elif h[i-1] - h[i] == 1 and h[i+1] >= h[i]:
        pass
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys
p = [[int(c) for c in r.split()] for r in sys.stdin.read().split('\n') if r != '']
n = p[0][0]
if n == 1:
    print('Yes')
    quit()
h = p[1]
h.reverse()
for i in range(len(h)-1):
    if h[i] + 1 < h[i+1]:
        print('No')
        quit()
    if h[i] < h[i+1]:
        h[i+1] -= 1
if h[i] < h[i+1]:
    print('No')
else:
    print('Yes')

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


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

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

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

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

for i in range(N-1, 1, -1):
    if inputs[i-1] > inputs[i]:
        inputs[i-1] -= 1

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

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

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

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

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

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

Solution (Python):
st_num = int(input())
st_hei = list(map(int, input().split() ))
max_hei = st_hei[-1]
this_bool = True
for i in reversed(range(0, st_num)):
 this_dif = (st_hei[i] - max_hei)
 if this_dif > 1:
  this_bool = False
  break
 elif this_dif > 0:
  max_hei = max_hei
 else:
  max_hei = st_hei[i]

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

Solution (Python):
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    if height[0] - height[1] <= 1:
        height[0] -= 1
    elif height[0] - height[1] > 1:
        flag = False
    
    for i in range(1,cell_num-1):
        if height[i] - height[i+1] > 1:
            flag = False
            break
        elif height[i] -  height[i+1] <= 1 and height[i-1] < height[i]:
            height[i] -= 1
        elif height[i] -  height[i+1] == 1 and height[i-1] == height[i]:
            flag = False
            break
            
if flag: print("Yes")
else: print("No")

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
lenH = len(H)
if lenH <= 1:
  print('Yes')
  exit()
for i in range(lenH-1):
  h_2 = H[lenH-i-1]
  h_1 = H[lenH-i-2]
  if h_2 < h_1:
    if h_1 - h_2 > 1:
      print('No')
      exit()
    else:
      H[lenH-i-2] -= 1
print('Yes')

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

Solution (Python):
n = int(input())
h = [int(i) for i in input().split()]
flag = 0
for i in range(n-1):
    if i==0:
        if h[i]-h[i+1]<=1:
            h[i] -=1
    else:
        if h[i-1]==h[i]:
            pass
        elif h[i-1]<h[i]:
            if h[i]-h[i+1]<=1:
                h[i]-=1
h1 = sorted(h)
if h==h1:
    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]: H[i+1]+=1

ans = 'Yes'

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