CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))
for i in range(1,n):
    if h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass
l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
h = list(map(int,input().split()))
h[0] -= 1
for i in range(1,n):
    if h[i-1] < h[i]:
        h[i] -= 1
l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')
# Original solution
n = int(eval(input()))
h = list([int(x) for x in input().split()])
f, mx = 0, 0
for hi in h:
    if hi > mx: mx = hi
    if hi <= (mx-2): f = 1; break
print(('YNeos'[f::2]))

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
f, mx = 0, 0
for hi in h:
    if hi > mx: mx = hi
    if hi <= (mx-2): f = 1; break
print(('YNeos'[f::2]))
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        for k in range(j,n-2):
            if h[k+1] - h[k+2] == 0:
                continue
            if h[k+1] - h[k+2] == 1:
                w = 0
                break
            break


        
if w == 0:
    print("No")
else:
    print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int,input().split()))

answer = "Yes"
for i in range(n-2,0,-1):
    if h[i] > h[i+1] + 1:
        answer = "No"
        break
    elif h[i] == h[i+1] +1:
        h[i] -= 1

print(answer)
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))
for i in range(1,N-1):
    if max(H[:i])-1>H[i+1]:
        print("No")
        break
else:
    print("Yes")

# Optimized solution
N=int(eval(input()))
H=list(map(int,input().split()))
a=0
for i in range(N-1):
    if a<H[i]:
        a=H[i]
    if a-1>H[i+1]:
        print("No")
        break
else:
    print("Yes")
# Original solution
import sys
n, hl = sys.stdin.readlines()
n = int(n)
hl = list(map(int, hl.split()))

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

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

# Optimized solution
import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

for i in range(n-1, 0,-1):
    if H[i] - H[i-1] ==-1:
        H[i-1]-=1
        
        
if sorted(H) == H:
    print('Yes')
else:
    print('No')
# Original solution
N = int(eval(input()))

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

# Optimized solution
N = int(eval(input()))

H = list(map(int, input().split()))
for i in range(1,N+1):
    tmp = H[-i]
    if not i==N:
        if tmp < H[-i-1]:
            if tmp == H[-i-1]-1:
                H[-i-1] -= 1
            else:
                print('No')
                exit()
print('Yes')
# Original solution
# -*- coding: utf-8 -*-
import copy

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

while H != sorted(H):
    for i in range(N-1):
        while H[i] > H[i+1]:
            H[i] -= 1

if all([abs(H[i]-H_bak[i]) < 2 for i in range(N)]):
    print("Yes")
else:
    print("No")


# Optimized solution
# -*- coding: utf-8 -*-

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

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

print(ans)
# Original solution
# ABC136 C - Build Stairs

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

# Optimized solution
N=int(eval(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")
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))
if N==1:
  print("Yes")
  exit()
for i in range(N-1):
  if H[i]-1<=H[i+1]:
    if i!=0:
      if H[i-1]<H[i]:
        H[i]-=1
  elif H[i]==H[i+1]:
    continue
  else:
    print("No")
    exit()
for i in range(N-1):
  if H[i]>H[i+1]:
    print("No")
    exit()
print("Yes")

# Optimized solution
N=int(eval(input()))
H=list(map(int,input().split()))
if N==1:
  print("Yes")
  exit()
if H[0]<H[1]:
  H[0]-=1
elif H[0]>H[1]:
  print("No")
  exit()
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")
# Original solution
n = int(eval(input()))
x = list(map(int, input().split(' ')))
for i in range(n-1):
    for j in range(i+1, n):
        if x[i] - x[j] >= 2:
            print('No')
            exit()

print('Yes')

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split(' ')))
now = 0
for i in range(n):
    if now < x[i]:
        now = x[i] - 1
    if now > x[i]:
        print('No')
        exit()

print('Yes')
# Original solution
n = int(eval(input()))
stair = input().split(' ')

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

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


print("Yes")


# Optimized solution
n = int(eval(input()))
stair = input().split(' ')

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

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit()
print("Yes")
# Original solution
n = int(eval(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")

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
a = H[0]
for i in range(1,N-1):
    a = max(H[i], a)
    b = H[i+1]
    if a - b >= 2:
        print("No")
        exit()
print("Yes")
# Original solution
N = int(eval(input()))
H=[int(x) for x in input().split()]

ans='Yes'
for n in range(N-1,0,-1):
    num=H[n]
    check=max(set(H[:n]))
    if check > num+1:
        ans='No'
print(ans)

# Optimized solution
N=int(eval(input()))
H=[int(x) for x in input().split()]

max_h=0
ans='Yes'

for n in range(N):
    if H[n] > max_h:
        max_h = H[n]
        
    if H[n] < max_h-1:
        ans='No'
        
print(ans)
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

mx = max(H)
ind = H.index(max(H))

if ind != N - 1 and mx - min(H[ind+1:]) > 1:
    print("No")
    exit()

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

print("Yes")

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
r_H = list(reversed(H))

for i in range(N-1):
    if r_H[i+1] - r_H[i] > 1:
        print("No")
        exit()
    if r_H[i+1] - r_H[i] == 1:
        r_H[i+1] = r_H[i+1] - 1
print("Yes")
# Original solution
N = int(eval(input()))
H = list(map(int,input().split()))
a = []
cnt = 0
for i in range(N-1):
  if cnt-H[i]>1:
    print("No")
    exit() 
  elif H[i]>H[i+1] and H[i]-H[i+1]==1:
    a.append(H[i]-1)
    cnt = max(cnt,H[i])
  elif H[i]<=H[i+1]:
    a.append(H[i])
    cnt = max(cnt,H[i])
  else:
    print("No")
    exit()
if cnt-H[N-1]>1:
  print("No")
  exit()
print("Yes")


# Optimized solution
N = int(eval(input()))
H = list(map(int,input().split()))
for i in range(N-2,-1,-1):
  if H[i]>H[i+1] and H[i]-H[i+1]==1:
    H[i] = H[i]-1
  elif H[i]<=H[i+1]:
    H[i] = H[i]
  else:
    print("No")
    exit()
print("Yes")
# Original solution
import sys
input = sys.stdin.readline

n=int(eval(input()))
h=list(map(int,input().split()))
l=h
s=[]
t=max(h)

for i in range(n-1):
        if l[i]-1==l[i+1]:
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]==l[i+1] and l[i]==t:
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]-1>l[i+1]:
                break
        elif l[i]-1<l[i+1]:
                s.append(l[i])
                continue

s.append(h[n-1])
s.sort()
if len(s)==n:
        if l==s:
                print('Yes')
        else:
                print('No')

else:
        print('No')




# Optimized solution
n=int(eval(input()))
h=list(map(int,input().split()))

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

else:
    c=0
    for i in range(n):
        if c<h[i]:
            h[i]-=1
            c=h[i]
        elif c==h[i]:
            c=h[i]
        else:
            print('No')
            break
    else:
        print('Yes')
# Original solution
from functools import reduce
_ = eval(input())
H = tuple(map(int, input().split()))
HH = reduce(lambda a, b: a+[b-1 if a[-1] < b else b], reversed(H), [float('inf')])
print(("Yes" if all(h1 >= h2 for h1, h2 in zip(HH, HH[1:])) else "No"))

# Optimized solution
from functools import reduce

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

_ = eval(input())
H = tuple(map(int, input().split()))
print(("No" if reduce(f, H) >= float('inf') else "Yes"))
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))
ans = "Yes"

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

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


# Optimized solution
import sys

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


def resolve():
    n = int(eval(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()
# Original solution
N = int(eval(input()))
H = [int(h) for h in input().split()]

if N == 1:
    ans = "Yes"
else:
    c = 0
    while c <= N-2:
        if H[c] < H[c+1]:
            H[c+1] -= 1
        c += 1
    List = []
    for j in range(N):
        List.append(H[j])
    List.sort()
    if List == H:
        ans = "Yes"
    else:
        ans = "No"

print(ans)

# Optimized solution
N = int(eval(input()))
H = [int(h) for h in input().split()]

ans = "Yes"
for i in range(1, N-1):
    if H[i] > H[i-1]:
        H[i] -= 1
    if H[i] > H[i+1]:
        ans = "No"
        break
print(ans)
# Original solution
N = int(eval(input()))
Hs = [int(i) for i in input().split()]

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

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


# Optimized solution
n = int(eval(input()))
nums = [int(num) for num in input().split()]


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


print((solve(nums)))
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))
h.reverse()

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

print('Yes')

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
h.reverse()

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

print('Yes')
# Original solution
N = int(eval(input()))
H = [i for i in map(int, input().split())]
ans ='Yes'
for idx in range(N):
  k = H[idx]
  for j in range(idx+1, N):
    if k - H[j] > 1:
      ans = 'No'
print(ans)
    

# Optimized solution
N = int(eval(input()))
H = [i for i in map(int, input().split())]
ans ='Yes'
temp_max =H[0]
for idx in range(N):
  if temp_max - H[idx] > 1:
    ans = 'No'
    break
    
  if temp_max < H[idx]:
    temp_max=H[idx]
  
print(ans)
# Original solution
import sys
N = int(eval(input()))
H = list(map(int, input().split()))

m = 0
for h in H:
    if m <= h-1 or m-1 <= h:
        m = max(m, h)
    else:
        print("No")
        sys.exit()

print("Yes")
        

# Optimized solution
import sys
N = int(eval(input()))
H = list(map(int, input().split()))

m = 0
for h in H:
    if m-1 <= h:
        m = max(m, h)
    else:
        print("No")
        sys.exit()

print("Yes")
# Original solution
n = int(eval(input()))
h = [int(x) for x in input().split()]

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

print('Yes')


# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))

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

print('Yes')
# Original solution
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(eval(input()))

def rl():
    return list(input().split())

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

def main():
    n = ri()
    lh = rli()
    for i in range(len(lh)-1):
        if lh[i+1] > lh[i]:
            lh[i+1] -= 1
        if lh[i+1] < lh[i]:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(eval(input()))

def rl():
    return list(input().split())

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

def main():
    n = ri()
    lh = rli()
    c = 0
    for h in lh:
        # print(c, h)
        if h < c:
            print("No")
            return
        elif h == c:
            c = h
        else:
            c = h-1
    print("Yes")


if __name__ == '__main__':
    main()
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))
flag=True
for i in range(1,N):
    if H[i]>H[i-1]:
        H[i]-=1
    elif H[i]==H[i-1]:
        pass
    elif H[i]<H[i-1]:
        flag=False
print(("Yes" if flag else "No"))

# Optimized solution
N=int(eval(input()))
H=list(map(int,input().split()))
pre=0
for h in H:
    if h<pre:
        print("No");exit()
    elif h>pre:
        pre=h-1
print("Yes")
# Original solution
n = int(eval(input()))
h = [int(i) for i in input().split()]
x = True
c = 0
for i in range(n):
    if i > 0 and h[i - 1] - h[i] >= 2:
        x = False
        break
    elif i > 0 and h[i - 1] - h[i] == 1:
        c += 1
    elif i > 0 and h[i] > h[i - 1] and c == 1:
        c = 0
    if c == 2:
        x = False
        break
if x:
    print("Yes")
else:
    print("No")

# Optimized solution
n = int(eval(input()))
h = [int(i) for i in input().split()]
for i in range(n - 1, 0, -1):
    d = h[i - 1] - h[i]
    if d > 1:
        print("No")
        break
    if d == 1:
        h[i - 1] -= 1
else:
    print("Yes")
# Original solution
n = int(eval(input()))
h = list(map(int, input().split()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    for i in range(2, len(h)):
        if h[i-1] - h[i] > 1:
            return('No')
        h[i] = max(h[i-1],h[i])
    return('Yes')
print((is_stairs(h)))

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    for i in range(1, len(h)):
        if h[i-1] - h[i] > 0:
            return('No')
        h[i] = max(h[i-1],h[i]-1)
        #print(h)
    return('Yes')
print((is_stairs(h)))
# Original solution
import sys
N = int(eval(input()))
Hs = list(map(int, input().split()))

prev_h = -1
downflg = False
for h in Hs:
    # 増加中
    if not downflg:
        if  h - prev_h >= 0:
            prev_h = h
        elif h - prev_h == -1:
            downflg = True
            prev_h = h
        else:
            print("No")
            sys.exit()
    # 減少中
    else:
        if h - prev_h > 0:
            downflg = False
            prev_h = h
        if h - prev_h == 0:
            prev_h = h
        else:
            print("No")
            sys.exit()
    # print(h,prev_h,downflg)
    prev_h = h
print("Yes")

# Optimized solution
N = int(eval(input()))
Hs = list(map(int, input().split()))[::-1]
# 後ろから貪欲のほうが良くない？
pre = 10**10
for h in Hs:
    # print(h)
    if pre - h  >= 0:
        pre = h
    elif pre - h == -1:
        pre = h -1 
    else:
        print("No")
        exit(0)
print("Yes")
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))

answer="Yes"

for i in range(N):
    if i>=1:
        if max(H[:i])>H[i]+1:
            answer="No"
            break
        else:
            pass
print(answer)

# Optimized solution
N=int(eval(input()))
H=list(map(int,input().split()))

answer="Yes"

for i in range(1,N,):
    if H[N-i]>=H[N-i-1]:
        pass
    else:
        H[N-i-1]-=1
        if H[N-i]<H[N-i-1]:
            answer="No"

print(answer)
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
H.reverse()
for i in range(1, N):
    if H[i-1] < H[i] - 1:
        print("No")
        break
    elif H[i-1] == H[i] - 1:
        H[i] -= 1
else:
    print("Yes")

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

# Optimized solution
# Coding by Rute
# C - Build Stairsの解説を始めます。
N = int(eval(input()))
H = list(map(int,input().split()))
f = 0 #フラグ関数です。
for i in range(1,N):
  if H[-(i+1)] <= H[-i]:
    #階段の高さが単調非減少かを調べます。
    continue
  else:
    if H[-(i+1)]-H[-i] == 1:
      #そうでない場合、高さが1小さければ、H[-(i+1)]を1小さくすれば良いです。
      #もし高さが2以上小さければ、その時点で単調非減少とすることができないのでフラグ関数に1を加えます。
      H[-(i+1)] -= 1
    else:
      f += 1
      break
if f == 0:
  print("Yes")
else:
  print("No")
#計算量は判定でO(N)かかります。
#以上、C - Build Stairsの解説でした。
# Original solution
n = int(eval(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'))


# Optimized solution
def main():
    N = int(eval(input()))
    *H, = list(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()
# Original solution
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

from collections import deque

def solve():
    n = II()
    H = LI()
    d = deque([])

    flag = True
    for i in range(0, n):
        hi = H[i]
        if i == 0:
            d.append(hi - 1)
            continue

        hp = d.popleft()
        if hp < hi:
            d.append(hi - 1)
        elif hp == hi:
            d.append(hi)
        else:   # hp > hi
            flag = False
            break

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







if __name__ == '__main__':
    solve()


# Optimized solution
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    H = LI()

    pre = -999
    flag = True
    for h in H:
        if pre <= h - 1:
            pre = h - 1
        elif pre <= h:
            pre = h
        else:
            flag = False
            break

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

if __name__ == '__main__':
    solve()
# Original solution
n = int(eval(input()))
L = list(map(int,input().split()))

if len(L)==1:
      flag = "Yes"
for i in range(1,n):
      if max(L[:i]) - min(L[i:]) >=2:
            flag = "No"
      else:
            flag = "Yes"

print(flag)


# Optimized solution
n = int(eval(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")
# Original solution
n = int(eval(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")

# Optimized solution
n = int(eval(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")
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
I = []
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        I.append(H[i])
I.append(H[N - 1])
N = len(I)
for i in range(N):
    for j in range(i + 1, N):
        if I[i] > I[j] + 1:
            print('No')
            quit()
print('Yes')

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
I = [H[i + 1] - H[i] for i in range(N - 1)]
N = len(I)
for i in range(N):
    if I[i] >= 0:
        continue
    elif I[i] < -1:
        print('No')
        quit()
    else:
        if i == N - 1:
            continue
        for j in range(i + 1, N):
            if I[j] >= 1:
                break
            elif I[j] <= -1:
                print('No')
                quit()
            else:
                continue
print('Yes')
# Original solution
n=int(eval(input()))
hi=[]
for i in map(int,input().split()):
    hi.append(i)
YesNo="Yes"    
for i in range(n-1,1,-1):
    if hi[i]+2<=hi[i-1]:
        YesNo="No"    
#        print("No")
        break
    elif hi[i]+1==hi[i-1]:
        hi[i-1]=hi[i-1]-1
print(YesNo)

# Optimized solution

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

yn=""
for i in  range(n-2,-1,-1):
    if h[i]<=h[i+1]:
        continue
    elif h[i]==h[i+1]+1:
        h[i]-=1
        continue
    else:
        yn="No"
        break
    
if yn=="No":
    print("No")
else:
    print("Yes")
# Original solution
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(eval(input()))
def S(): return eval(input())
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
if N==1:
    print('Yes')
    exit()
if N==2:
    print(('Yes' if H[0]-1<=H[1] else 'No'))
    exit()
for i in range(N-1):
    if i==0:
        H[i] -= 1
        continue
    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')


# Optimized solution
def I(): return int(eval(input()))
def LI(): return list(map(int,input().split()))
##################################################
N = I()
H = LI()
for i in range(N):
    if i==0:
        H[i] -= 1
        continue
    if i==N-1:
        if H[i-1]<=H[i]:
            continue
    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')
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
# print(N, H)

ret = 'Yes'

for i in range(N):
	for j in range(i, N):
		if H[i]-1 > H[j]:
			ret = 'No'
			break

	if ret == 'No':
		break

print(ret)


# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))

ret = 'Yes'
bar = H[0] - 1

for i in range(1, N):
	if bar > H[i]:
		ret = ('No')
		break
	elif bar < H[i]:
		bar = H[i] - 1

print(ret)