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

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
h = LI()
for i in range(n):
    if i == 0:
        h[i] -= 1
        continue
    if h[i-1] < h[i]:
        h[i] -= 1
    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]:
        print('No')
        import sys
        sys.exit()
    if h[i-1] <= h[i]-1:
        h[i] -= 1
print('Yes')

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

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

max_H = H[0]
for i in range(1, n):
    if H[i-1]>H[i]:
        max_H = max(H[i-1], max_H)
        if abs(max_H - H[i])>1:
            print('No')
            exit()
print('Yes')

Solution (Python):
N = int(input())
H = [int(x) for x in input().split()]
for i in range(N - 2, -1, -1):
  if H[i] > H[i + 1] + 1:
    print('No')
    break
  if H[i] > H[i + 1]:
    H[i] -= 1
else:
  print('Yes')

Solution (Python):
n = int(input())
num_list = [ int(v) for v in input().split() ]
num_list[0] -= 1
for i in range(n-1):
    if num_list[i] < num_list[i+1]:
        num_list[i+1] -= 1

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

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

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

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

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

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

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

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

h.reverse()

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

Solution (Python):
def find(A):
    if A[0]>1:
        A[0]-=1
    for i in range(1,len(A)):
        if A[i]>A[i-1]:
            A[i]-=1
        
        elif A[i]==A[i-1]:
            continue
        else:
            return "No"
    return "Yes"
input()
A=list(map(int,input().strip().split(' ')))
print(find(A))

Solution (Python):
import sys

n=int(input())
a=list(map(int,input().split()))
a.reverse()
res=True
for i in range(1, n):
  if a[i-1]+1<a[i]:
    res&=False
  if a[i-1]+1==a[i]:
    a[i]-=1
print("Yes" if res else "No")

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

ans = 'Yes'
for i in range(N):
    if H[i-1] <= H[i] - 1:
        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()]

H.reverse()

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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
h_list=list(map(int,input().split()))
h_list[0]-=1
import sys
for i in range(1,n):
    if h_list[i]==h_list[i-1]:
        pass
    elif h_list[i]>h_list[i-1]:
        h_list[i]-=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-i-1]<h[n-i-2]:
        h[n-i-2]-=1

for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        quit()
print("Yes")

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

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

cur = h[-1]
i = n - 2
flg = True
while i >= 0:
    if h[i] <= cur + 1:
        cur = min(cur, h[i])
    else:
        flg = False
        break
    i -= 1

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

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

prev = 10 ** 10
for i in range(N):
    ind = N-i-1
    cur = H[ind]
    if cur == prev + 1:
        continue
    else:
        if cur > prev + 1:
            print('No')
            exit()
        prev = cur

print('Yes')

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:
        Flag = False
        break
    if H[i - 1] == H[i] + 1:
        H[i - 1] -= 1

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

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


def f():
    prev = h[0] - 1
    for i in range(1, n):
        if prev > h[i]:
            return False
        prev = max(prev, h[i]-1)
    return True


print(['No', 'Yes'][f()])

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

Solution (Python):





def main():
  N = int(input())
  Hn = list(map(int, input().split()))
  for i in range(1,N):
    if Hn[i-1] < Hn[i]:
      Hn[i] -= 1
    elif Hn[i-1] > Hn[i]:
      return False
  return True

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

Solution (Python):

n = int(input())
H = [int(el) for el in input().split(' ')]

max_h = 0
for i in range(n):
    if H[i] < max_h:
        print('No')
        break

    if H[i] -1 >= max_h:
        max_h = H[i] - 1
else:
    print('Yes')

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

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

H.reverse()

for i in range(N-1):
    if H[i] < H[i+1]:
        if H[i+1] - H[i] == 1:
            H[i+1] -= 1
        else:
            print("No")
            sys.exit(0)
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]:
        h[i - 1] -= 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()))

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

Solution (Python):




def main():
  input()
  values = list(map(int, input().split()))[::-1]

  for i in range(1, len(values)):
    if values[i] <= values[i - 1]:
      continue
    elif values[i] == values[i - 1] + 1:
      values[i] -= 1
    else:
      print('No')
      return

  print('Yes')


if __name__ == '__main__':
  main()

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

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

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

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

Solution (Python):
def main():
    n = input()
    hh = map(int, raw_input().split())
    for i in xrange(n - 1, 0, -1):
        if hh[i - 1] <= hh[i]:
            continue
        elif hh[i - 1] - 1 == hh[i]:
            hh[i - 1] -= 1
        else:
            print 'No'
            return
    print "Yes"


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial

def main():
    num = int(input())
    data = list(map(int, input().split()))

    now_num = data[0]

    for i in range(1, num):
        if data[i] > now_num:
            now_num = data[i] - 1
        elif data[i] == now_num:
            pass
        else:
            print('No')
            sys.exit()

    print('Yes')






if __name__ == '__main__':
    main()

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

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

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

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

B=A[::-1]

for i in range(1,N):
    if B[i]<=B[i-1]:
        pass
    else:
        if B[i]==B[i-1]+1:
            B[i]-=1
        else:
            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]:
    h[i-1]-=1
H=sorted(h)
if H==h:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
h = list(map(int, input().split()))
ans = True
left = 0
for i in h:
    if left > i:
        ans = False
        break
    elif left < i:
        left = i -1
    elif left == i:
        continue
if ans:
    print("Yes")
else:
    print("No")

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

Solution (Python):
N = int(input())
s = list(map(int,input().split()))
_max = s[0]
maxes = []
for i in s:
  maxes.append(max(_max,i))
  _max = max(_max,i)

if all([ k-j<=1 for j,k in zip(s,maxes)  ]):
  print("Yes")
else:
  print("No")

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

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

flag = False
is_pos = True

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

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

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

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

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

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
prev = H[-1]
for h in H[::-1]:
  if h <= prev:
    prev = h
    continue
  if h-1 <= prev:
    prev = h-1
    continue
  print('No')
  quit()
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] > h[i-1]:
        h[i] -= 1
cur = h[0]
for i in range(1, n):
    if h[i] < cur:
        print('No')
        exit()
    else:
        cur = h[i]
print('Yes')

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    H = get_li()
    if n == 1:
        print('Yes')
        return
    m = H[0]
    for h in H[1:]:
        if h > m:
            m = h
        elif m - 1 > h:
            print('No')
            return
    print('Yes')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Solution (Python):
import sys

n = int(input())
h_list = list(map(int, input().split()))
for i in range(n - 1):
    if h_list[i] <= h_list[i+1]:
        continue
    if h_list[i] - h_list[i+1] > 1:
        print('No')
        sys.exit()
    else:
        h_list[i+1] += 1
print('Yes')

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

flg = True
for i in range(n-1):
    if h[n-1-i] + 1 < h[n-2-i]:
        flg = False
        break
    
    if h[n-1-i] < h[n-2-i]:
        h[n-2-i] -= 1

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

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

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

def check(h_list):
	prev = 0
	for h in h_list:
		if prev > h:
			return False
		elif prev < h:
			prev = h - 1
	return True

if check(h_list):
	print("Yes")
else:
	print("No")

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

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

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


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

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

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] -=1
ans="Yes"
for i in range(n-1):
    if H[i]>H[i+1]:
        ans="No"

print(ans)

Solution (Python):
import sys

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

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

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

    if H[i-1] > H[i]:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N = int(input())
    H = [int(a) for a in input().split()]
    
    
    
    
    

    m = MAX
    for hi in reversed(H):
        if hi > m + 1:
            print("No")
            return
        m = min(hi, m)
    print("Yes")


if __name__ == '__main__':
    main()

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

m = 0
for i in range(N):
    if m <= h[i]:
        m = h[i]
    else:
        diff = abs(m - h[i])
        if diff >= 2:
            print('No')
            exit()

print('Yes')

Solution (Python):


import sys

n = int(input())

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

a[0] = a[0]-1

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

print('Yes')

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

maxh = h[0]
flag = True
for i in range(1, n):
    if maxh - h[i] > 1:
        flag = False
    
    if h[i] > maxh:
        maxh = h[i]
        
if flag:
    print("Yes")
else :
    print("No")

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
maxi = H[0]
flag = True
for h in H[1:]:
    if maxi > h + 1:
        flag = False
    elif  h > maxi:
        maxi = h
print("Yes" if flag else "No")

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

ans = "Yes"
for i in range(1, n):
	if heights[i] > heights[i-1]:
		heights[i] -= 1
	if heights[i] < heights[i-1]:
		ans = "No"
		break

print(ans)

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    H = LIST()

    tmp = 1
    for i in range(N):
        if tmp < H[i]:
            tmp = H[i] - 1
        elif tmp > H[i]:
            No()
            exit()
    Yes()
    
if __name__ == '__main__':
    main()

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

mina = a[-1]
ok = True

for ai in a[::-1]:
    mina = min(ai, mina)
    if ai - mina >= 2:
        ok = False
        break

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

Solution (Python):
N = int(input())
H = list(map(int,input().split()))
if N == 1:
    print("Yes")
    exit()

for i in range(N-2,-1,-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())
A = list(map(int, input().split()))
p = 0
for a in A:
  if p > a:
    print('No')
    exit()
  if p < a:
    p = a - 1
print('Yes')

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")

Solution (Python):

N = int(input())
H = list(map(int,input().split()))
import sys
tmp = H[0]
for h in H[1:]:
    if tmp < h:
        tmp = h-1
    elif tmp == h:
        tmp = h
    else:
        print('No')
        sys.exit()
    
    
print('Yes')

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

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

ue = 0
flag = "Yes"

for i in range(n):
    if(hs[i]>ue):
        ue = hs[i]
    elif(ue-2>=hs[i]):
        flag = "No"
        break
    
  
print(flag)

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]






N = int(input())
H = [0] + list(map(int, input().split()))

t = H[1] - 1
ans = "Yes"
for i in range(2, N+1):
    now = H[i]
    if t > now:
        ans = "No"
        break
    else:
        t = max(t, now-1)
print(ans)

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

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

for i in range(N-1):
  if hlist[i]>hlist[i+1]:
    print("No")
    break
else:
  print("Yes")

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

p = H[0]
for h in H[1:]:
    if h > p + 1:
        print('No')
        exit()
    else:
        p = min(h,p)

print('Yes')

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

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

Solution (Python):
def inpl():
    return list(map(int, input().split()))


N = int(input())
H = inpl()
H[0] -= 1
for i in range(1, N):
    if H[i] > H[i - 1]:
        H[i] -= 1
    elif H[i] == H[i - 1]:
        continue
    else:
        print("No")
        exit()

print("Yes")

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

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

arr.reverse()

now = arr[0]
flag = True
for i in range(1,n):
    if arr[i] > now+1:
        flag = False
        break
    elif arr[i] == now or arr[i] == now+1:
        continue
    else:
        now = arr[i]

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

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

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

print("Yes")

Solution (Python):
N = int(input())
H = [int(x) for x in input().split()]
last = H[-1]
for i in H[::-1]:
    if(i>last):
        if(i!=last+1):
            print('No')
            break
        else:
            last = i-1
    else:
        last = i
else:
    print('Yes')

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

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

v = 1
flag = True
for i in range(n):
    if v < h[i]:
        v = h[i] - 1
    elif v == h[i]:
        pass
    else:
        flag = False
        break

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
H = LI()

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

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

pre = -1
f1 = f2 = True
for num in H:
    if pre < num:
        f1 = f2 = True
    elif pre == num:
        pass
    elif pre == num + 1 and f1:
        f1 = False
        f2 = True
    else:
        print "No"
        exit()
    pre = num
print "Yes"

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

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

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

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

H = H[::-1]

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

print('Yes')

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))



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

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

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

Solution (Python):
N = int(input())
H = [int(zz) for zz in input().split()][::-1]
p = H[0]

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

print('Yes')

Solution (Python):
n=int(input())
H=[int(i) for i in input().split()]
ans=True
prev=0
for i in range(n):
  if H[i]<prev:
    ans=False
  if H[i]>prev:
    prev=H[i]-1
  else:
    prev=H[i]
print("Yes" if ans==True else "No")

Solution (Python):
n = int(input())
hs = list(map(int, input().split()))
hs.reverse()
current = 1000000000
for h in hs:
  if h > current + 1:
    print('No')
    exit(0)
  current = min(current, h)

print('Yes')

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

tmp = 0
for i in range(n):
    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()))

for i in reversed(range(N-1)):
    if Hs[i]-1 > Hs[i+1]:
        print('No')
        break
    elif Hs[i]-1 == Hs[i+1]:
        Hs[i] -= 1
    else:
        pass
else:
    print('Yes')

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

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

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

prev = 0
for item in hs:
    if item >= prev:
        prev = item
    elif item == prev - 1:
        prev = item + 1
    else:
        print("No")
        exit()

print("Yes")