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

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


for i,h in enumerate(h_list[::-1]):
    if i != 0:
        if prev - h >= 0:
            prev = h
        elif prev - h == -1:
            prev = h - 1
        else:
            print('No')
            sys.exit()
    else:
        prev = h
    
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]>=h[i-1]:
        continue
    elif h[i]+1==h[i-1]:
        h[i-1]-=1
    else:
        ans='No'
print(ans)

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

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

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

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

for i in range(1,n):
    a = h[i-1] - h[i]
    if a > 1:
        break
    elif a == 1:
        if f == 1:
            break
        f = 1
    elif a == 0:
        pass
    else:
        f = 0

    if i == n - 1:
        f = 2

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

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

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

    if H[index] > H[index + 1]:
        print("No")
        exit()
    
print("Yes")

Solution (Python):
def solve():
    N, *sl = map(lambda x: int(x), open(0).read().split())
    ans = "Yes"
    s_max = sl[0]
    for i in range(1, N):
        a = sl[i]
        if s_max > a + 1:
            ans = "No"
            break
        s_max = max(s_max, a)
    print(ans)  
if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())
if(N == 1):
  print("Yes")
  exit()

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

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

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

success = True
m = -1
for i in range(n):
    m = max(m, h[i])
    if m - 1 > h[i]:
        success = False
        break

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

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

Solution (Python):
n = int(input())
hs = list(map(int, input().split()))
max = hs[0]
prev = -1
flag = False
for v in hs:
    if v <= prev - 1 and v < max - 1:
        flag = True
        break
    if v > max:
        max = v
    prev = v
if flag:
    print('No')
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")
            break
else:
    print("Yes")

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

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

    if flag<=-1:
      print("No")
      exit()
  elif h[i+1]-h[i]>=1:
    flag=1
  
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-1] - h[i] > 1:
        print('No')
        exit()
    elif h[i-1] - h[i] == 1:
        h[i-1] -= 1
    else:
        pass

print('Yes')

Solution (Python):
def t(h):
    a = True
    for i, x in enumerate(h[:-1]):
        if x > h[i + 1]:
            if x - 1 > h[i + 1] or a is False:
                return 'No'
            else:
                a = False
        elif x < h[i + 1]:
            a = True
    return 'Yes'


if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    print(t(h))

Solution (Python):
input()
seq = [int(x) for x in input().split()]
min_val = seq[0]
for val in seq[1:]:
  if val < min_val:
    print('No')
    break
  elif min_val != val:
    min_val = val -1
  
else:
	print('Yes')

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  elif before-l[i]==0:continue
  else:d=0
  before=l[i]
print("Yes")

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

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

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

H.reverse()

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

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

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

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

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

Frg = True 

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

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

Solution (Python):
def solve():
    n = int(input())
    H = [int(i) for i in input().split()]
    for i in range(n-1)[::-1]:
        if H[i+1]<H[i]:
            H[i]=H[i]-1
        if H[i+1]<H[i]:
            return 'No'
    else:
        return 'Yes'

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

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

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

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

Solution (Python):

N = int(input())
W = list(map(int, input().split()))
judge = True

for i in range(N-1):
  if W[i]<W[i+1]:
    W[i+1]-=1
  if W[i]>W[i+1]:
    judge = False
    break
print('Yes' if judge else 'No')

'''
in [1]:
  4
  4 3 5 6
out [1]:
  No
'''

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N,*H = map(int,read().split())

prev = 0
bl = True
for i in range(N):
    if H[i] - 1 >= prev:
        H[i] -= 1
    if H[i] < prev:
        bl = False
        break
    prev = H[i]

answer = 'Yes' if bl else 'No'
print(answer)

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

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


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

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

print('Yes')

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

Solution (Python):
N = input()
H = list(map(int, input().split()))
cur = 1e10
H.reverse()
for h in H:
	if(cur >= h):
		cur = h
	elif(cur == h - 1):
		cur = h -1
	else:
		print("No")
		exit(0)
print("Yes")

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

for h in H:
    second_H = h
    if first_H <= second_H or first_H <= second_H - 1:
        first_H = max(second_H-1, first_H)
    else:
        print("No")
        finish = 1
        break
if finish != 1:
    print("Yes")

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  a = na()

  for i in range(n - 1, 1, -1):
    if a[i] > a[i - 1]:
      continue
    if a[i] < a[i - 1]:
      if a[i] == a[i - 1] - 1:
        a[i - 1] -= 1
        continue
    if a[i] == a[i - 1]:
      continue
    print("No")
    return
  print("Yes")
main()

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

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

print("Yes")

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    H = [int(n) for n in input().split()]
    nums = H[::-1]
    ret = 'Yes'
    for idx, n in enumerate(nums[1:]):
        if n >= nums[idx] + 2:
            ret = 'No'
        elif n == nums[idx] + 1:
            nums[idx + 1] -= 1
    print(ret)

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

flg=True
temp_max=0

for i in range(N-1):
    if H[i] - H[i+1] >= 2:
        flg=False
        break
        
    if temp_max - H[i+1] >= 2:
        flg=False
        break
    elif temp_max<H[i+1]:
        temp_max = H[i+1]
if flg:
    print("Yes")
else:
    print("No")

Solution (Python):

def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    if N == 1:
        print('Yes')
        return
    elif N == 2:
        if H[0] - H[1] > 1:
            print('No')
        else:
            print('Yes')
        return
    for idx in range(len(H)-2):
        
        if H[idx] - H[idx+1] > 1 or H[idx] - H[idx+2] > 1:
            print('No')
            return
        if H[idx] - H[idx+1] == 1:
            H[idx+1] += 1
    print('Yes')


if __name__ == "__main__":
    main()

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

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

print('Yes')

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

    for i in reversed(range(n - 1)):
        if h[i] > h[i + 1]:
            h[i] -= 1
            if h[i] > h[i + 1]:
                return False
    
    return True

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

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

before = H[-1]
for h in H[::-1]:
    if h - before > 1:
        print('No')
        break
    if h - before == 1:
        before = h - 1
    else:
        before = h
else:
    print('Yes')

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

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

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

h_new=sorted(h)
        
if h == h_new:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'

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

print(ans)

Solution (Python):
from sys import exit

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

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

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

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

now=H[0]
for i in H:
        if i>now:
                now=i
        elif now>i+1:
                print('No')
                exit()

print('Yes')

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


can = True
for i in range(n-1, 1, -1):
  if n == 1:
    break
  elif h[i-1] <= h[i]:
    continue
  elif (h[i-1] - 1) <= h[i]:
    h[i-1] -= 1
    continue
  else:
    can = False
    break

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

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

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

print("Yes")

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

print(ans)

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

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

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

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
if n == 1:
    print('Yes')
else:
    i = 0
    f = 0
    while i < n-1:
        if h[i]-h[i+1] > 1:
            print('No')
            i = n 
        elif h[i]-h[i+1] == 1:
            f += 1
            if f == 2:
                print('No')
                i = n
            else:
                i += 1
        elif h[i] == h[i+1]:
            i += 1
        else:
            f = 0
            i += 1
    if i == n-1:
        print('Yes')

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
rH = list(reversed(H))
for idx, val in enumerate(rH):
    if idx == len(rH) - 1:
        break
    if rH[idx + 1] > val:
        rH[idx + 1] -= 1
        if rH[idx + 1] > val:
            print('No')
            exit()
print('Yes')

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


former_height = H_l[0]

for idx in range(1,N):
    if H_l[idx] - former_height >= 1:
        H_l[idx] -= 1
        former_height = H_l[idx]
    elif H_l[idx] - former_height < 0:
        print("No")
        exit()

print("Yes")

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

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

print("Yes")

Solution (Python):
n = int(input())
li_h = list(map(int, input().split()))
save_h = 0
for idx, h in sorted(enumerate(li_h), reverse=True):
    if idx == n - 1:
        save_h = h
    else:
        if h <= save_h:
            save_h = h
        elif (h - save_h) == 1:
            save_h = h - 1
        else:
            print("No")
            exit(0)
else:
    print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(h[i], minimum)
  if h[i] > minimum + 1:
    print("No")
    exit()
print("Yes")

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

h.reverse()

for i in range(1,N):
    d=h[i-1]-h[i]
    if d<=-2:
        print("No")
        break
    else:
        if d==-1:
            h[i]=h[i]-1
        else:
            pass
        if i==N-1:
            print("Yes")
if N==1:
    print("Yes")

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

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

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

Solution (Python):
n = int(input())
array = [int(x) for x in input().split()]
flag = True
for i in range(n):
    if i == 0:
        continue
    else:
        if array[i] < array[i-1]:
            flag = False
        else:
            if array[i-1] != array[i]:
                array[i] -= 1
print("Yes" if flag else "No")

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

Solution (Python):
def main():
    H = map(int, open(0).read().split()[:0:-1])
    pre = None
    for h in H:
        if pre is None:
            pre = h
        elif h <= pre:
            pre = h
        elif pre + 1 == h:
            continue
        else:
            
            print("No")
            return

    print("Yes")
    return


main()

Solution (Python):
def main():
    H = map(int, open(0).read().split()[:1:-1])
    pre = None
    for h in H:
        if pre is None:
            pre = h
        elif h <= pre:
            pre = h
        elif pre + 1 == h:
            continue
        else:
            
            print("No")
            return

    print("Yes")
    return


main()

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

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

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

print("Yes")

Solution (Python):
def main():
    H = map(int, open(0).read().split()[:1:-1])
    pre = None
    for h in H:
        if pre is None:
            pre = h
        if pre + 1 < h:
            print("No")
            return
        if pre + 1 == h:
            pre = h - 1
        else:
            pre = h

    print("Yes")
    return


main()

Solution (Python):
def main():
    H = map(int, open(0).read().split()[:1:-1])
    pre = None
    for h in H:
        if pre:
            if pre + 1 < h:
                print("No")
                return
            elif pre + 1 == h:
                pre = h - 1
            else:
                pre = h
        else:
            pre = h

    print("Yes")
    return


main()

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

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

Solution (Python):
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)

Solution (Python):
n = int(input())
a_list = list(map(int, input().split()))
a_list.reverse()
result = True
for i in range(n-1):
  if a_list[i+1] >= a_list[i]+2:
    result = False
    break
  elif a_list[i+1] == a_list[i]+1:
    a_list[i+1] -= 1
  if i == n-2 and a_list[i+1] <= a_list[i]:
    result = True
if result:
  print("Yes")
else:
  print("No")

Solution (Python):
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)

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


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


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():

    N = int(input())
    H = list(map(int, input().split()))
    prev = float('-inf')
    for i in range(len(H)):
        if H[i] > prev: prev = H[i]-1
        elif H[i] == prev: pass
        else: return "No"

    return "Yes"

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

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

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

cur = H[0]

f = True
for hi in H[1:]:
  if cur <= hi:
    cur = hi
  elif cur <= hi + 1:
    cur = hi + 1
  else:
    f = False

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

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

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

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

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

for i in range(n,1,-1):
      if L[i-1]<L[i-2]:
            L[i-2]-=1
            if L[i-1]<L[i-2]:
                  print("No")
                  exit()
print("Yes")

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

temp = H[-1]

for i in range (2,N+1):
    if(temp < H[(-1)*i]-1):
        print("No")
        exit()
    else:
        if(temp != H[(-1)*i] - 1):
            temp = min(temp,H[(-1)*i])
print("Yes")

Solution (Python):
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

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

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

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

H_max = 0
flag = True
for i in range(N):
    if H_max < H[i]:
        H_max = H[i]
    if H_max - H[i] >= 2:
        flag = False
        break

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

Solution (Python):
N = int(raw_input())
H = map(int,raw_input().split())
ans = "Yes"

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

Solution (Python):
n = int(input())
heights = [int(h) for h in input().split()]
current = heights[0] - 1

for h in heights[1:]:
    if current < h:
        current = h - 1
    elif current == h:
        current = h
    else:
        current = -1
        break

if current < 0:
    print("No")
else:
    print("Yes")

Solution (Python):
N = int(input())
Hn = list(map(int, input().split()))
Hn.reverse()
if N==1:
  print('Yes')

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

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

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))+[10**9]

    ans = "Yes"

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

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

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

print("Yes")

Solution (Python):



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

high=l[0]
for i in range(N-1):
    if l[i+1]-l[i]<(-1):
        print("No")
        exit()
    high=max(high,l[i+1])
    if l[i+1]<(high-1):
        print("No")
        exit()
        
print("Yes")

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

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

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

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

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

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

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

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

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

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

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

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

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

left = h[0]

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

print('Yes')

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

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

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

print(ans)

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

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

print('Yes')

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

ans = "Yes"
now = 10 ** 9 + 1

for i in range(n - 1, -1, -1):
	for j in range(2):
		tmp = h_list[i] - j
		if tmp <= now:
			now = tmp
			break
		if j == 1:
		  ans = "No"
		
print(ans)

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

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

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

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

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