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())
a=list(map(int, input().split()))
ans='Yes'
now=a[0]-1
for i in a: 
    if now>i:
        ans='No'
    now=max(now, i-1)
print(ans)

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

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    H=LI()[::-1]
    for i,h in enumerate(H):
        if i == 0:
            pass
        else:
            if h <= H[i-1]:
                continue
            else:
                H[i]-=1
                if H[i] > H[i-1]:
                    print("No")
                    exit()
            

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

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

    p = 0
    for i in h:
        if i > p:
            p = i - 1
        elif i < p:
            print('No')
            return

    print('Yes')




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

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

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

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

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")
        break
else:
    print("Yes")

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

print('Yes')

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

ans = True
m = 10**10
for i in reversed(range(n)):
    if h[i] <= m:
        m = h[i]
    elif h[i] > m+1:
        ans = False
        break

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))

n = onem()

l = l()
if n == 1:
    print("Yes")
    exit()
else:
    k = l[0]

for i in range(1,n):
    if l[i]-1 >= k:
        k = l[i]-1
    elif l[i] == k:
        k = l[i]
    else:
        print("No")
        exit()
print("Yes")

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

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    ok = 1
    for i in reversed(range(n - 1)):
        if arr[i] > arr[i + 1]:
            arr[i] -= 1
        if arr[i] > arr[i + 1]:
            ok = 0
    
    if ok:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

Solution (Python):
N = int(input())
H = list(map(int, input().split()))
pre = 0
ans = 'Yes'
for h in H:
    if pre > h:
        ans = 'No'
        break
    if pre <= h-1:
        pre = h-1
    else:
        pre = h

print(ans)

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

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

Solution (Python):
def main():
    n = int(input())
    hts = list(map(int,input().split()))
    hts[0] -= 1
    for i in range(1,n):
        if hts[i] > hts[i-1]:
            hts[i] -= 1

    for i in range(1,n):
        if hts[i] < hts[i-1]:
            print('No')
            return

    print('Yes')


main()

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

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


a = 0
for i in h:
    if i < a: break
    elif i > a:
        a = i-1

else:
    print("Yes")
    exit()

print("No")

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N = int(input())
H = inpl()
cur = 0
for h in H:
    if h > cur:
        cur = h - 1
    elif h < cur:
        print('No')
        break
else:
    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()]

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

print('Yes')

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

flg = True
for i in range(1, N + 1) :
    if H[i] != H[i-1] :
        H[i] -= 1
    if H[i] < H[i-1] :
        flg = False
        
if flg :
    print('Yes')
else :
    print('No')

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

now = h_array[0]
for i in h_array[1:]:
    if now <= i or now <= i-1:
        now = max(i-1, now)
        pass
    else:
        print("No")
        exit()
else:
    print("Yes")

Solution (Python):


import sys

class CBuildStairs:
    def solve(self):
        n = int(input())
        h = [int(_) for _ in input().split()]
        for i in range(1, n):
            if h[i] < h[i - 1]:
                print("No")
                break
            elif h[i] > h[i - 1]:
                h[i] -= 1
        else:
            print("Yes")

solver = CBuildStairs()
input = sys.stdin.readline

solver.solve()

Solution (Python):
import os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations
from sys import stdin,setrecursionlimit
from copy import deepcopy
setrecursionlimit(10**6)

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

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

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

print(ans)

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

print('Yes')

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

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7












N = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

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

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

Solution (Python):
N = int(input())
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):
import sys

stdin = sys.stdin

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

n = ni()
h = na()

prev = 999999999999
for i in range(n-1,-1,-1):
    if h[i] > prev:
        h[i] -= 1
    if h[i] > prev:
        print("No")
        sys.exit(0)
    prev = h[i]
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):

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  
NO = "No"  

def solve(N: int, H: "List[int]"):
    for i in range(1, N):
        if H[i] > H[i - 1]:
            H[i] -= 1
        elif H[i] < H[i - 1]:
            print(NO)
            return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    H = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, H)

if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    a,b,c = LI()
    c -= a-b
    print(max(0,c))
    return


def B():
    n = I()
    ans = 0
    for i in range(1,n+1):
        s = str(i)
        if len(s)%2:
            ans += 1
    print(ans)
    return


def C():
    n = I()
    h = LI()
    h[0] -= 1
    for i in range(n-1):
        if h[i+1] < h[i]:
            print("No")
            return
        if h[i+1] > h[i]:
            h[i+1] -= 1
    print("Yes")
    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    C()

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()))
v = -float("inf")
for h in H:
    if v > h:
        if v != h+1:
            print("No")
            exit()
        else:
            v = h+1
    else:
        v = h
print("Yes")