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()))
h = h[::-1]
count = 0
for i in range(1, n):
    if h[i]-h[i-1]==1:
        h[i]+=-1
    elif h[i]-h[i-1]>=2:
        print('No')
        exit()
print('Yes')

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

Solution (Python):
def main():
    N = int(input())
    H = [int(i) for i in input().split()]
    for i in range(N-1)[::-1]:
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                return print("No")
    print("Yes")


if __name__ == '__main__':
    main()

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

mx = H[0]
for h in H[1:]:
    if h < mx-1:
        print('No')
        exit()
    mx = max(mx, h)
print('Yes')

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

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

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

m = 0
for i,j in enumerate(H):
    if i==0:
        m = j
    if m-j>1:
        print("No")
        break
    m = max(m, j)
else:
    print("Yes")

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

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

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

print("Yes")

Solution (Python):
from functools import reduce

def f(m, h):
    if h < m - 1:
        return float('inf')
    return max(m, h)

_ = input()
H = tuple(map(int, input().split()))
print("No" if reduce(f, H) >= float('inf') else "Yes")

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

if N == 1:
    print("Yes")
else:
    is_clear = True
    for n in range(N-1):
        if H[n] >= H[n+1]:
            pass
        elif H[n+1] - H[n] == 1:
            H[n+1] -= 1
        else:
            is_clear = False
            break

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

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

pre_n = nums[0]
output = 'Yes'
for i in range(1, len(nums)):
  n = nums[i]
  if pre_n < n:
    if pre_n < n - 1:
      output = 'No'
      break
    else:
      pre_n = n - 1
  else:
    pre_n = n
print(output)

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))[::-1]
last=10**10
for i in lst:
    if last >=i:
        last=i
    elif last==i-1:
        last=i-1
    else:
        print("No")
        exit(0)
print("Yes")

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

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

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

Solution (Python):





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

    ans = 'Yes'
    
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]: continue
        if h[i-1]-1 == h[i]:
          h[i-1] = h[i-1] - 1
          continue
        ans = 'No'
        break
    print(ans)
    
if __name__ == '__main__':
    main()

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

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

ans = "Yes"
for i in reversed(range(len(h)-1)):
    d = h[i+1] - h[i]
    if d == -1:
        h[i] -= 1
    elif d < -1:
        ans = "No"

print(ans)

Solution (Python):
N = int(input())
H = list(int(x) for x in input().split())
max = H[0]
ans = True

for i in range(N):
    if max < H[i]:
        max = H[i]
    elif max - 2 >= H[i]:
        ans = False
        break

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

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

Solution (Python):
n = int(input())
s = list(map(int, input().strip().split(" ")))

flg = 0

for i in range(n-1):
    if s[i] - s[i+1] >= 2 or (s[i-1] ==  s[i] and s[i+1] - s[i] < 0):
        print("No")
        flg = 1
        break
    elif  s[i] - s[i+1] == 1:
        s[i] -= 1
    elif s[i] - s[i-1] >= 1:
        s[i] -= 1

if flg == 0:
    print("Yes")

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

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]:
        H[i] -= 1
print('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No')

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]:
        H[i] -= 1

if all(H[i-1] <= H[i] for i in range(1, n)):
    print('Yes')
else:
    print('No')

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

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

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

ans = "Yes"

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

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

for i in range(2,n+1):
    if tmp - h[-i] == -1:
        tmp = h[-i]-1
    elif tmp - h[-i] < -1:
        ans = 'No'
        break
    else:
        tmp = h[-i]

print(ans)

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

result = 'Yes'

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

print(result)

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

max_h = 0
possible = True
for x in h:
    if max_h - 1 > x:
        possible = False
        break
    elif max_h <= x - 1:
        max_h = x


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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
now = a[0]-1
for i in range(1,n):
    if now < a[i]:
        now = a[i]-1
    elif now == a[i]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def check():
    N = int(input())
    H = [int(i) for i in input().split()]
    
    max_h = 0
    
    for h in H:
        if max_h-1 > h:
            return 'No'
        if max_h <= h-1:
            max_h = h
    return 'Yes'
  
print(check())

Solution (Python):




def solve(N, H):
    for i in range(N - 1):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        elif H[i] > H[i+1]:
            return 'No'
    return 'Yes'


N = int(input())


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








print(solve(N, H))

Solution (Python):
import sys

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

ans = 'Yes'

li.reverse()

for index, i in enumerate(li):
  if index + 1 > len(li) - 1:
    break

  if i < li[index+1]:
    li[index+1] -= 1

    if i < li[index+1]:
      print("No")
      sys.exit()

print("Yes")

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

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

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    H = cin.mapInt()
    for i in reversed(range(N - 1)):
        d = H[i] - H[i + 1]
        if d <= 0:
            continue
        if d == 1:
            H[i] -=1
        else:
            print("No")
            return
    print("Yes")
    return

if __name__ == "__main__":
    main()

Solution (Python):


n = int(input())
l = [int(x) for x in input().split()]

for i in range(n-1)[::-1]: 
    if l[i] - 1 == l[i+1]:
        l[i] = l[i] - 1 
    else:
        continue

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else: 
    print('Yes')

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


for i in range(n-1)[::-1]:
    if l[i] - 1 == l[i+1]:
        l[i] = l[i] - 1
    else:
        continue
    


a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
flag = True
for i in range(n-1):
    if h[i+1] - h[i] >= 1:
        h[i+1] -= 1
    elif h[i+1] -h[i] == 0:
        pass
    else:
        flag = False
        break
if flag:
    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] -= 1
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    flag = True

    for i in range(n-1):
        if num_list[i] != 1 and num_list[i-1] < num_list[i]:
            num_list[i] -= 1
        if num_list[i]  > num_list[i+1]:
            flag = False
            break
            
    print('Yes' if flag else 'No')

if __name__ == '__main__':
    main()

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

for i in range(N-1,0,-1):
    
    if (Height[i] >= Height[i-1]):
        continue
    
    elif (Height[i] == Height[i-1]-1):
        Height[i-1] -= 1
    
    else:
        judge = 'No'
        break

print(judge)

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

stairs = list(map(int, input().split(" ")))
min = 0

for i in range(N):
    stair = stairs[i]
    if min > stair:
        print("No")
        exit(0)
    if stair - 1 > min:
        min = stair - 1

print("Yes")

Solution (Python):
def solve(n, H):
    m = H[0]
    for i in range(1, n):
        if m - H[i] > 1:
            return 'No'
        if m < H[i]:
            m = H[i]
    return 'Yes'

_n = int(input())
_H = list(map(int, input().split()))
print(solve(_n, _H))

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

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

print(result)

Solution (Python):
n,*h=map(int,open(0).read().split())
h.reverse()
base=h[0]
flg=True
for i in h:
  if i > base:
    if i-1 > base:
      flg=False
      break
  elif i < base:
    base = i
print("Yes" if flg else "No")

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

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

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

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

tmp = 0
for h in l:
  if h > tmp:
    tmp = h-1
  if h < tmp:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
n=int(input())
hi=[]
for i in map(int,input().split()):
    hi.append(i)
YesNo="Yes"    
for i in range(n-1,1,-1):
    if hi[i]+2<=hi[i-1]:
        YesNo="No"    

        break
    elif hi[i]+1==hi[i-1]:
        hi[i-1]=hi[i-1]-1
print(YesNo)

Solution (Python):
import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
h[0] -= 1
for i in range(1, n-1):
    dif_1 = h[i] - h[i+1]
    dif_2 = h[i] - h[i-1]
    if dif_1 > 1:
        print(ans)
        sys.exit()
    elif dif_1 == 1 or dif_2 > 0:
        h[i] -= 1


max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif < 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

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

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

h=[int(x) for x in input().split()]


flag = True

if n==1:
    print('Yes')
else:
    for i in range(n-1):
        l=h[i]
        r=h[i+1]
        if l < r:
            h[i+1]-=1
        else:
            h[i+1]=l
        if l > r:
            flag=False

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

Solution (Python):
def LI():
	return [int(s) for s in input().split()]
  
N = int(input())
A_s = LI()

success_flag = True

for i in range(N-2,-1,-1):
  if A_s[i+1] < (A_s[i]-1):
    success_flag = False
    break
  elif  A_s[i+1] < A_s[i]:
    A_s[i]=A_s[i]-1

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

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

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

Solution (Python):
n = int(input())
stair = input().split(' ')

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

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())
stair = input().split(' ')

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

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit()


print("Yes")

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

Solution (Python):
N = int(input())
Hs = list(map(int, input().split()))
 
tmp = Hs[0]
for h in Hs:
    if tmp - h > 1:
        print("No")
        exit()
    if h > tmp:
        tmp = h
print("Yes")

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

tmp = Hs[0]
for h in Hs:
    if tmp - h > 1:
        print("No")
        exit()
    if h > tmp:
        tmp = h
print("Yes")

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

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

is_Yes = True
for i in range(1, N):
    if Hs[i-1] == Hs[i]:
        continue
    elif Hs[i] > Hs[i-1]:
        Hs[i] -= 1
    else:
        is_Yes = False
        break

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

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

for i in range(n-1, 0, -1):
  sa = h[i-1] - h[i]
  
  if sa > 1:
    print("No")
    exit()
  elif sa > 0:
    h[i-1] -= 1
  else:
    pass

print("Yes")

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

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

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

ht=h[-1]
ans="Yes"
for i in reversed(h):
  if 0 <= i <= ht+1:
    if ht+1 == i:
      ht = i-1
    else:
      ht = i
  else:
    ans="No"
    break
    
print(ans)

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

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

if __name__ =="__main__":
    main()

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

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

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

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

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

Solution (Python):
def solve():
    N = int(input())
    H = list(map(int, input().split()))
    h_max = H[0]
    ret = True
    for h in H:
        if h_max-1 > h:
            ret = False
            break
        if h_max < h:
            h_max = h
    print('Yes' if ret else 'No')
    
solve()

Solution (Python):
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))
H = H[::-1]

for i in range(len(H) - 1):
    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):
def solve():
    N = int(input())
    H = list(map(int, input().split()))

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

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
HS=LI()

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

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

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


print(ans)

Solution (Python):
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1] - 1
        if not h[i-1] <= h[i]:
            print('No')
            return
        else:
            continue
    print('Yes')

if __name__ == '__main__':
    main()

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

for i in range(n-2, -1, -1):
    if hi[i] > hi[i+1]:
        if hi[i] - hi[i+1] != 1:
            print('No')
            exit()
        else:
            hi[i] -= 1
print('Yes')

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


if __name__ == '__main__':
    main()

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

s=0
flag = True

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

for i in range(N-1):
    s = max(s,H[i])
    if s-H[i+1]>1:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

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

ans = 'Yes'
if len(H) == 1:
  print(ans)
  exit(0)

for i in range(1, len(H)):
  if H[i-1] < H[i]:
    H[i] -= 1
  if H[i-1] > H[i]:
    ans = 'No'
    break

print(ans)

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

ans = 'Yes'
if len(H) == 1:
  print(ans)
  exit(0)

for i in range(1, len(H)):
  if H[i-1] < H[i]:
    H[i] -= 1
  if H[i-1] > H[i]:
    ans = 'No'
    break

print(ans)

Solution (Python):

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

def solve():
  h[0]-=1
  for i in range(1,n):
    if h[i] > h[i-1]:
      h[i]-=1
    elif h[i] == h[i-1]:
      pass
    else :
      return 0
  return 1
    

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

Solution (Python):

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

def solve():
  h[0]-=1
  for i in range(1,n):
    if h[i] > h[i-1]:
      h[i]-=1
    elif h[i] == h[i-1]:
      pass
    else :
      print('No')
      return 0
  return 1
    

if solve():
  print('Yes')

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

mi = -1
rs = 'Yes'
for i in range(n):
    if mi < H[i]:
        mi = H[i] - 1
    elif mi > H[i]:
        rs = 'No'
        break
print(rs)

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

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

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

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

Solution (Python):
N = int(input())
H = [i for i in map(int,input().split())]
ok=1
for i in range(N-1,0,-1):
  if H[i-1] > H[i]:
    H[i-1] -= 1

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

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+1)]:
        H[-(i+1)] = H[-(i+1)]-1
    elif H[-i]+1 < H[-(i+1)]:
        ans ="No"
        break
print(ans)

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

ceil=0
ans="Yes"
for i in range(N):
    if H[i]>ceil:
        ceil=H[i]
    if H[i]<ceil-1:
        ans="No"
        break
print(ans)

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

print(ans)

Solution (Python):
import sys

def main():
    N = int(sys.stdin.readline().rstrip())
    H = list(map(int, input().split()))


    for x in reversed(range(1, N)):
        if H[x] >= H[x-1]:
            pass

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

        else:
            print('No')
            sys.exit()

    print('Yes')


main()

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
H = [int(i) for i in input().split()]
ans = True
prev = -999
peek = 0
for i in range(N):
    h = H[i]
    if prev <= H[i] - 1:
        prev = H[i] - 1
    elif prev <= H[i]:
        prev = H[i]
    else:
        ans = False
        break
print("Yes" if ans else "No")

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

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

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

mh=0
ans='Yes'
for i in range(n):
    if mh-h[i]>=2:
        ans='No'
        break
    if h[i]>mh:
        mh=h[i]
print(ans)

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

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

    for i in range(N-1):
        if h[-(i+1)] < (h[-(i+2)]-1):
            return "No"
        elif h[-(i+1)] >= h[-(i+2)]:
            pass
        else:
            h[-(i + 2)] = h[-(i + 2)] - 1
    return "Yes"

if __name__ == '__main__':
    print(main())

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

i = -1
for _ in range(n - 1):
    if H[i - 1] - H[i] > 1:
        ans = "No"
        print(ans)
        exit()
    elif H[i - 1] - H[i] == 1:
        H[i - 1] -= 1
    i -= 1

ans = "Yes"
print(ans)

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

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

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

if H == sorted(H):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
f = True
now = H[0]
for i in range(0,N - 1):
  
  
  if now - H[i + 1] >= 1:
    f = not f
    break
  
  elif H[i + 1] - now >= 1:
    now = H[i + 1] - 1

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

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

i = -1
for _ in range(n - 1):
    if H[i - 1] - H[i] > 1:
        ans = "No"
        print(ans)
        exit()
    elif H[i - 1] - H[i] == 1:
        H[i - 1] -= 1
    i -= 1

ans = "Yes"
print(ans)

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

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

if __name__ == "__main__":
    main()