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

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

ans = "Yes"

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

Solution (Python):
from sys import stdin, setrecursionlimit


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

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

    print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

for i in range(N-1):
    if i==0:
        is_equal_to_left = False
    else:
        is_equal_to_left = H[i-1] == H[i]
    
    if is_equal_to_left:
        pass
    else:
        H[i] -= 1

        
H_sorted = sorted(H)

if H == H_sorted:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
h = [int(x) for x in input().split()]
a = h[0]
ans = 'Yes'
for i in range(1, n-1):
    a = max(h[i], a)
    b = h[i+1]
    if a - b >= 2:
        ans = 'No'
        break
print(ans)

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

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


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

    print("No")
    break

else:
    print("Yes")

Solution (Python):

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


h.reverse()
flag = True
for i in range(n-1):
  if h[i+1] == h[i]+1:
    h[i+1] -= 1
  if h[i+1] > h[i]+1:
    flag = False
    break


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

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

a = ln[-1]
check = 'T'
for i in range(n-2,-1,-1): 
    if ln[i] <= a :
        a = ln[i]
    elif ln[i]-1 == a:
        a = ln[i]-1
    else:
        check = 'F'
        break
if check == 'T':
    print('Yes')
else:
    print('No')

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

ck = False
for i in range(n-2,-1,-1):
  if h[i] > h[i+1]:
    h[i] -= 1
    if h[i] > h[i+1]:
      break
else :
  ck = True

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

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
tmpmax=A[0]
ikeru=True
ok=True
for i in range(1,N):
  if tmpmax>A[i]:
    if tmpmax-1==A[i] and ok:
      tmpmax-=1
      ok=False
    else:
      ikeru=False
      break
  elif tmpmax<A[i]:
    ok=True
    tmpmax=A[i]

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

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

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

print(ans)

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

pre = float('INF')
isOK = True
for i in range(n-1,-1,-1):
    if(pre >= H[i]):
        pre = H[i]
        continue
    if(pre == (H[i]-1)):
        H[i] -= 1
        pre = H[i]
        continue
    isOK = False
    break
    

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

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

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

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

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

Solution (Python):


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

h.reverse()


ans = 0
for i in range(1, len(h)):
    if h[i-1]-h[i] >= 0:
        continue
    elif h[i-1]-h[i] == -1:
        h[i] -= 1
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
from sys import exit

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

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

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

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

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

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

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

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

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')

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

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

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

Solution (Python):
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    prev_a = A[0]
    max_a = A[0]
    for a in A[1:]:
        if a + 1 < prev_a or a + 1 < max_a:
            print("No")
            break
        elif prev_a == a:
            prev_a = a
            max_a = max(max_a, a)
        else:
            prev_a = a - 1
            max_a = max(max_a, a)
    else:
        print("Yes")
    
    
if __name__ == '__main__':
    main()

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()
    
print('Yes')

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

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

for j in range(N-1):
    if H[j] > H[j+1]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    for hh in h:
        if hh < pre-1:
            print('No')
            return
        pre = max(pre, hh)
        
    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]:
		print("No")
		break
	if H[i] < H[i+1]:
		H[i+1] -= 1
else:
	print("Yes")

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



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

print("Yes")

Solution (Python):

import sys
input = sys.stdin.readline









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

ans = "Yes"

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

print(ans)

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



def main():
    N = int(input())
    Hs = list(map(int, input().split()))

    for i in reversed(range(1, N)):
        if Hs[i] - Hs[i-1] == -1:
            Hs[i-1] -= 1
        elif Hs[i] - Hs[i-1] <= -2:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

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

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)









n=n0()
h=n1()

c=h[n-1]
f=True
for i in range(n-2,-1,-1):
    if c>h[i]:
        c=h[i]
    elif c+1>=h[i]:
        continue
    else:
        f=False
        break
    
p0(f)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)









n=n0()
h=n1()

c=h[n-1]
f=True
for i in range(n-1,-1,-1):
    if c>h[i]:
        c=h[i]
    elif c+1>=h[i]:
        continue
    else:
        f=False
        break
    
p0(f)

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

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

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

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

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

Solution (Python):

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

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

print('Yes')

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

    cond = True
    p = H[0] - 1
    for h in H[1:]:
        if p < h:
            p = h - 1
        elif p == h:
            pass
        else:
            cond = False
            break

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


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
H=list(map(int,input().split()))
base=0
for h in H:
    if base>h:
        print("No")
        break
    base=max(base,h-1)
else:
    print("Yes")

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

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

ans = 'Yes'
for j in range(n-1):
    if h[j] < h[j+1]:
        print('No')
        sys.exit()

print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    N = int(input())
    h = list(map(int, input().split()))[::-1]
    for i in range(N-1):
        if h[i] < h[i+1]:
            if h[i+1]-h[i] > 1:
                ans='No'
                break
            else:
                h[i+1] -= 1

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


N = inp()
a = inlist()
res = "Yes"
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+1] < a[i]:
        res = "No"
        break
print(res)

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

print("Yes")

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

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

H = 0
ck = 0

for i in range(N):
  a = List[i]
  if a >= H:
    if a-1 >= H:
      H = a -1
    else:
      H = a
  else:
    ck = 1

print("Yes" if ck == 0 else "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")
        exit()
    
    if h[i] == h[i+1]+1:
        h[i+1] += 1
    
print("Yes")

Solution (Python):
import sys
N = int(input())
boxes = list(map(int,input().split()))
prev = 10**9+1
for box in boxes[::-1]:
    if prev - box > -1:
        prev = box
    elif prev - box == -1:
        prev = box -1
    else:
        print("No")
        sys.exit()
print("Yes")

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

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

max_h = 0
ans = 'Yes'
for h in H:
    if max_h < h:
        max_h = h

    if max_h - 1 > h:
        ans = "No"
        break

print(ans)

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

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

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

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

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

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

flg = True
for i in range(n - 1):
    if h[i] > h[i + 1]:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')

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

current_max_H = -1
for i in range(N):
    if H[i] > current_max_H:
        current_max_H = H[i]
    if H[i] >= current_max_H - 1:
        continue
    else:
        print("No")
        break

else:
    print("Yes")

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
H = IL()

now = H[0]-1

for i in range(1,N):
  if H[i]>now:
    now = H[i]-1
  elif H[i] == now:
    continue
  else:
    NE()
Y()

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

now = 0
for i in h:
    if now < i:
        now = i - 1
    elif now == i:
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n = int(input())
h = list(map(int,input().split()))
ok = True
ans = -1000001000
for i in range(n):
    if ans <= h[i] - 1:
        ans = h[i] - 1
    elif ans <= h[i]:
        ans = h[i]
    else:
        ok = False
        break
if ok:
    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

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

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

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

for i in range(1, N):
    if hh[i - 1] == hh[i]:
        continue
    else:
        hh[i] -= 1
    if hh[i - 1] > hh[i]:
        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]-1:
        h[i] -= 1
    elif h[i-1] > h[i]:
        print("No")
        exit()
print("Yes")

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

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

    if H[i - 1] < H[i]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import sys

import math
from fractions import Fraction
import itertools

input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
s=set()
for i in range(n-1):
    if a[n-1-i-1]>1+a[n-i-1]:
        print("No")
        exit()
    elif a[n-i-2]==a[n-i-1]+1:
        a[n-i-2]-=1
        s.add(i)
for i in range(n-1):
    if a[i]>a[i+1] and i in s:
        print("No")
        exit()
print("Yes")

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

cri = 0
for i in range(n-1):
    if h[i] <= h[i+1]:
        continue
    else:
        cri = max(cri, h[i+1])
        if h[i] - h[i+1] > 1 or cri > h[i+1]:
            print("No")
            exit()
else:
    print("Yes")

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

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

Solution (Python):
N = int(input())
H = list(map(int, input().split()))[::-1]
last = 10 ** 10
ans = 'Yes'
for hi in H:
    if last >= hi:
        last = hi
    elif last >= hi - 1:
        last = hi - 1
    else:
        ans = 'No'
print(ans)

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

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

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

ans = 'Yes'
H_floor = 0
for h in H:
    if h - H_floor < 0:
        ans = 'No'
        break
    else:
        H_floor = max(H_floor, h - 1) 
        
print(ans)

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

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
h=lmp()
for i in range(n-1):
    if h[n-i-2]-h[n-i-1]>=2:
        print("No")
        exit()
    if h[n-i-2]-h[n-i-1]==1:
        h[n-i-2]-=1
print("Yes")

Solution (Python):
def resolve():
  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 h[i-1] > h[i]:
      print('No')
      return
  print('Yes')

  return

if __name__ == "__main__":
  resolve()

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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 j in range(1, n):
        if H[j - 1] > H[j]:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

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

Solution (Python):
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    OK = True
    for i in range(1, len(h)):
        if h[i] == h[i-1]:
            continue
        elif h[i] > h[i-1]:
            h[i] -= 1
        else:
            OK = False
            break
    if OK:
        print("Yes")
    else:
        print("No")
resolve()

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

    for i in range(1,n)[::-1]:
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1]-1
        if h[i-1] > h[i]:
            print('No')
            return 0
    print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
def build_stairs(n, hli):

    ans = "Yes"

    for i in range(1, n):
        if hli[i-1] < hli[i]:
            hli[i] -= 1
        elif hli[i-1] == hli[i]:
            pass
        else:
            return "No"

    return ans

def main():
    n = int(input())
    hli = list(map(int, input().split()))
    print(build_stairs(n, hli))

if __name__ == '__main__':
    main()

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

print('Yes')

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

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

print('Yes')

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = [x-1 if x != 1 else 1 for x in a]

for i in range(n-1):
    a[i+1] = a[i+1] if abs(a[i]-a[i+1]) < abs(a[i]-b[i+1]) else b[i+1]
    if a[i+1] < a[i]:
        print('No')
        quit()

print('Yes')

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

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

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

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

for i in range(n-1,0,-1):
    if h[i] != h[i-1]:
        if h[i] - h[i-1] < -1:
            print("No")
            sys.exit()
        elif h[i] - h[i-1] < 0:
            h[i-1] -= 1

print("Yes")

Solution (Python):
N=int(input())
ls=[int(s) for s in input().split()]
ls.reverse()
for i in range(1,N):
  if ls[i]<=ls[i-1]:
    continue
  if ls[i]==ls[i-1]+1:
    ls[i]-=1
  else:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
import sys
n, *lst = map(int, sys.stdin.read().split())

a = lst[-1]
for i in lst[::-1]:
  if i > a + 1:
    print('No')
    quit()
  if i < a:
    a = i
else:
  print('Yes')

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

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

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

Solution (Python):
n=int(input())
a=[0]*n
a[:]=map(int,input().split())
a0=a[0]
for ii in range(n):
  if a[ii]<a0:
    
    print("No")
    exit()
  else:
    a0=max(a0,a[ii]-1)
print("Yes")

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

Max=0
i=0
while i<N:
    
    if List[i]-Max <= -2:
        print("No")
        quit()
    Max=max(Max,List[i])
    
    i+=1

print("Yes")

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

Solution (Python):


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

past_H = 0
can_substract = False

for i in range(1, N - 1):

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

    if (H_list[i] - H_list[i + 1] == 1) and (H_list[i] - H_list[i - 1] < 1):
        print('No')
        exit()

    if H_list[i] - H_list[i - 1] >= 1:
        H_list[i] -= 1
        continue

print('Yes')

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
f = 0
li.append(10**9+1)
if li[0] - 1 <= li[1]:
    li[0] = li[0] - 1
else:
    print("No")
    exit()
for i in range(n-1):
    if li[i] <= li[i+1] - 1:
        li[i+1] = li[i+1] - 1
    elif li[i] == li[i+1]:
        continue
    else:
        print("No")
        f += 1
        break
if f == 0:
    print("Yes")

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
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-1,0,-1):
    if H[i] < H[i-1]:
        H[i-1] -= 1
    if H[i] < H[i-1]:
        print('No')
        exit()
print('Yes')

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

for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    if H[i] > H[i+1]:
        ans = 1
        break

if ans == 0:
    print('Yes')
else:
    print("No")