CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

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

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

prev = -1
flag = True
for x in H:
  if x < prev:
    flag = False
    break
  if x == prev:
    continue
  prev = x - 1
  
print(("Yes" if flag else "No"))
# Original solution
n = int(eval(input()))
tall = list(map(int, input().split()))
maxhigh = [i for i, x in enumerate(tall) if x == max(tall)]
minhigh = [i for i, x in enumerate(tall) if x == min(tall)]

if(n == 1):
    print("Yes")
elif((max(tall) - min(tall)>= 2)and(min(maxhigh)>max(minhigh))):
    print("Yes")
else:
    print("No")


# Optimized solution
n = int(eval(input()))
tall = list(map(int, input().split()))
lar = tall[0]
lno = 0
frag = 0


for i in range(n):
    if(tall[i]>lar):
        lar= tall[i]
    if(lar - tall[i] >= 2):
        frag = 1
        break

if(frag == 1):
    print("No")
else:
    print("Yes")
# Original solution
#!usr/bin/env python3
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

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

#B
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

#C
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

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.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 solve():
    n = I()
    h = LI()
    m = h[0]-1
    for i in h[1:]:
        if m > i:
            print("No")
            return
        m = max(m,i-1)
    print("Yes")
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
for i in range(1,N):
  diff = H[i] - H[i-1]
  if diff > 0:
    H[i] -= 1
  if diff < 0:
    print('No')
    exit()
print('Yes')

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
pre = None
for i in H[::-1]:
  if pre == None:
    pre = i
    continue
  elif i < pre:
    pre = i
    continue
  elif i <= pre+1:
    continue
  print('No')
  exit()
print('Yes')
# Original solution
N=int(eval(input()))
H=list(map(int,input().split()))[::-1]
flag=True
base=H[0]
for i in range(N-1):
    if H[i]+1==H[i+1]:
        H[i+1]-=1
    elif H[i]>=H[i+1]:
        continue
    else:
        flag=False
print(("Yes" if flag else "No"))

# 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()))
ans = True

for i in range(len(h)-1):
    if h[i] > (min(h[i+1:]) + 1):
        ans = False
if ans:
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
ans = True
m = h[0]
for i in range(1, len(h)):
    if h[i] + 1 < m:
        ans = False
    m = max(m, h[i])
if ans:
    print('Yes')
else:
    print('No')
# Original solution
n = int(eval(input()))
h = list(map(int,input().split()))
M = h[0]
for i in range(n-1):
    if h[i] >= h[i+1] + 2:
        print("No")
        exit()

    if M > h[i+1] + 1:
        print("No")
        exit()

    M = max(M,h[i+1])
print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int,input().split()))
M = h[0]
for i in range(n-1):
    if M > h[i+1] + 1:
        print("No")
        exit()

    M = max(M,h[i+1])
print("Yes")
# Original solution
N = int(eval(input()))
H = [int(x) for x in input().split()]
# print(N,H)
result = "Yes"

for i in range(len(H)-1):
    if (H[i]-1 > min(H[i+1:])):
        result = "No"
        break

print(result)

# Optimized solution
N = int(eval(input()))
H = [int(x) for x in input().split()]
# print(N,H)
result = "Yes"
top = 0
for i in range(len(H)):
    if (H[i] < top-1 ):
        result = "No"
        break
    top = max(top, H[i])

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

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


# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    H = [int(h) for h in input().split()]
    for i in reversed(list(range(N-1))):
        if H[i] > H[i + 1]: H[i] -= 1
        if H[i] > H[i + 1]: 
            print("No")
            break
    else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

flag = True

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

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

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

flag = True

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

if flag:
    print("Yes")
else:
    print("No")
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))

res = True
if N >= 2:
    for i in range(N - 1):
        for j in range(1, N - i):
            if H[i] - H[i + j] >= 2:
                res = False
                break
        if res == False:
            break

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

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

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

y_card = 0
if N >= 3 and res == True:
    for i in range(N - 1):
        if H[i] - H[i + 1] == 1:
            y_card += 1
            if y_card == 2:
                res = False
                break
        elif H[i] == H[i + 1]:
            pass
        elif H[i + 1] - H[i] >= 1:
            y_card -= H[i + 1] - H[i]
            if y_card < 0:
                y_card = 0


if res == True:
    print('Yes')
else:
    print('No')
# Original solution
n=int(eval(input()))
h=list(map(int,input().split()))
temp=0
if n==1:
  print("Yes")
else:
  for i in range(0,n-1):
    tempmax=min(h[i+1:])
    if h[i]-1>tempmax:
      temp=1
      break
  if temp==0:
    print("Yes")
  else:
    print("No")

# 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 = [int (i) for i in input().split()]
flag = 1

if N == 1:
    flag = 1
else:
    for i in range(N-2,-1,-1):
        if H[i] > H[i+1]:
            H[i] -= 1
    for i in range(N-1):
        if H[i] > H[i+1]:
            flag = 0

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


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

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

if flag == 0:
    print("No")
else:
    print("Yes")
# Original solution
N = int(eval(input()))
A = [0]*(N)
H = list(map(int, input().split()))
ans = "Yes"

hmax = max(H)
k = H.index(hmax)
Hd = [0]*k

for i in range(k):
    Hd[i]=H[i]
    if H[i]<max(Hd)-1:
        ans = "No"


for i in range(k,N,1):
    if H[i]<hmax-1:
        ans = "No"


print(ans)



# Optimized solution
N = int(eval(input()))
A = [0]*(N)
H = list(map(int, input().split()))
ans = "Yes"

hmax = max(H)
k = H.index(hmax)
Hd = [0]*k
Hdmax=int(0)
for i in range(k):
    Hd[i] = H[i]
    Hdmax = max(Hdmax,Hd[i])
    if H[i] < Hdmax - 1:
        ans = "No"

for i in range(k,N,1):
    if H[i]<hmax-1:
        ans = "No"


print(ans)
# Original solution
N = int(eval(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")

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

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

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

for i in range(1,N):
	if max(X[:i])-min(X[i:]) > 1:
		print("No")
		exit()
print("Yes")

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

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

maxlst = []
minlst = []
R = 10**10
L = 0
for i in range(N):
	L = max(X[i],L) 
	maxlst.append(L)
	R = min(X[-i-1],R)
	minlst.append(R)

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

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

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

H[0] -= 1

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

print('Yes')
# Original solution
N = int(eval(input()))
H = list(map(int,input().split()))
ans = "Yes"
RMH = [0]*N
# 右端から右からi番目の要素のうち最小の値
for i in range(N):
  if i == 0:
    RMH[i] = H[-i-1]
  else:
    RMH[i] = min([RMH[i-1],H[-i-1]]) #reversed

# 左からi番目の要素が、左からi+1番目から右端の要素の最小値との差が常に１以下ならOK
for i in range(N-1):
  if H[i] - RMH[-i-2] > 1:
    ans = "No"

print(ans)

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
H.reverse()
def main():
  for i in range(N-1):
    if (H[i+1] - H[i] >= 2):
      print("No")
      return
    if (H[i+1] - H[i] == 1):
      H[i+1] -= 1
  print("Yes")

main()
# Original solution
n = int(eval(input()))
listH = list(map(int, input().split()))

for i in range(0, n-1):
    if(listH[i+1] - listH[i] == -1):
        listH[i+1] += 1
    if(listH[i+1] - listH[i] < -1):
        print("No")
        quit()


print("Yes")

# Optimized solution
n = int(eval(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] < -1:
        print("No")
        quit()

print("Yes")
# Original solution
def move_mass(h_list, h_moved_flag):
  for index in range(0,n-1):
    if h_list[index] > h_list[index+1] and h_moved_flag[index] is False:
      h_list[index] = h_list[index]-1
      h_moved_flag[index] = True
  return h_list, h_moved_flag
################################
n = int(eval(input()))
if n == 1:
  print("Yes")
  exit()

h_list = [int(h) for h in input().split()]
h_moved_flag = [False for i in range(n)]
for index in range(1000):
  h_list, h_moved_flag = move_mass(h_list, h_moved_flag)
  
  not_dec_flag = False
  for index in range(0,n-1):
    if h_list[index] > h_list[index+1]:
      not_dec_flag = True
  
  if not_dec_flag == False:
    print("Yes")
    exit()
print("No")

# Optimized solution
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

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

for i in range(1,N):
  dif = H[i] - H[i-1]
  if dif >= 0: continue
  elif dif == -1: H[i] += 1
  else:
    print('No')
    exit()
print('Yes')
# Original solution
n = int(eval(input()))
l = [int(x) for x in input().split()]
#print(l)

for i in range(n-1)[::-1]:
    if l[i] - 1 == l[i+1]:
        l[i] = l[i] - 1
    else:
        continue
    
#print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


# Optimized solution
# アルゴリズムを思いつけなかった！

n = int(eval(input()))
l = [int(x) for x in input().split()]

for i in range(n-1)[::-1]: #右からループ
    if l[i] - 1 == l[i+1]:# 右より1大きい場合にのみ
        l[i] = l[i] - 1 # 1引く
    else:
        continue

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else: # forをbreakすることなく完了した場合に稼働
    print('Yes')
# Original solution
import sys

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

n_str = str(n)
li_size = len(li)

for i in range(li_size):
  li_contents = li[i] - 1
  for j in range(li_size - i):
    if li_contents > li[j + i]:
      print("No")
      sys.exit()
print("Yes")


# Optimized solution
import sys

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

n_str = str(n)
li_size = len(li)
max = li[0]
for i in range(li_size):
  if max == li[i]:
    continue
  elif max > li[i]:
    print("No")
    sys.exit()
  elif max < li[i]:
    max = li[i] - 1
print("Yes")
# Original solution
n=int(eval(input()))
il=list(map(int, input().split()))
yn="Yes"
l=len(il)
for i in range(1, l):
    if i == 0:
        continue
    for j in range(0,i-1):
        if il[j] > il[i] + 1:
            yn = "No"
            break
print(yn)

# Optimized solution
n=int(eval(input()))
il=list(map(int, input().split()))
m=il[0]
yn="Yes"
for a in il[1:]:
    if m - 1 <= a:
        m=max([m, a])
        continue
    yn="No"
    break
print(yn)
# Original solution
N = int(eval(input()))
*H, = list(map(int, input().split()))

m = 0
for i,j in enumerate(H):
    if i==0:
        m = j
    if m-j>1:
        print("No")
        break
    m = max(m, j)
else:
    print("Yes")


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

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

check = True
for i in range(0,N-1):
  if H[i] - min(H[i+1:]) >= 2:
    check = False

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

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

check = True

for i in range(N-1):
  if H[i] >= H[i+1]:
    continue
  else:
    if H[i+1] - H[i] > 1:
      check = False
      break
    else:
      H[i+1] -= 1
      
if check:
  print("Yes")
else:
  print("No")
# Original solution
n=int(eval(input()));sa=[0]*n
h=list(map(int,input().split()))
for i in range(n):
    for j in range(n):
        try:
            if h[j]>h[j+1] and sa[j]!=1:
                h[j]=h[j]-1
                sa[j]=1
        except IndexError:
            pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")

# Optimized solution
n=int(eval(input()))
h=list(map(int,input().split()))
h[0]=h[0]-1
for i in range(1,n):
    try:
        if h[i-1]<=h[i]-1:
            h[i]=h[i]-1
    except IndexError:
        pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")
# Original solution
import heapq

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

for i in range(1, n):
  h_minus = list([x*(-1) for x in h[:i]])
  heapq.heapify(h_minus)
  if h[i] < (h_minus[0])*(-1)-1:
    print("No")
    exit(0)
print("Yes")

# Optimized solution
n = int(eval(input()))
h = list(map(int, input().split()))
   
h_max = h[0]
for i in range(1, n):
  if h[i-1] > h_max:
    h_max = h[i-1]
  if h[i] < h_max -1:
    print("No")
    exit(0)
print("Yes")
# Original solution
import sys

n = int(eval(input()))
h = list(map(int, input().split()))
max_ = h[0]

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

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

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i + 1] >= 2:
        print("No")
        exit()
print("Yes")
# Original solution
n=int(eval(input()))
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(H)-H[-1]>1:
        print("No")
        exit(0)
print("Yes")

# Optimized solution
n=int(eval(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")
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
prev = float('inf')
for h in H[::-1]:
    if h - prev > 1:
        print('No')
        break
    prev = h - (h > prev)
else:
    print('Yes')


# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
m = H[0]
for h in H[1:]:
    if m - h > 1:
        print('No')
        break
    m = max(m, h)
else:
    print('Yes')
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
count = 0
max_i = 0
H.append(10**9 + 2)
for i in range(N):
  if H[i] > H[i + 1] + 1:
    count += 1
  if max_i - H[i] > 1:
    count += 1
  max_i = max(H[:i+1])

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

# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
count = 0
max_i = 0
H.append(10**9 + 2)
for i in range(N):
  if H[i] > H[i + 1] + 1:
    count += 1
  if max_i - H[i] > 1:
    count += 1
  max_i = max(max_i,H[i])

    
if count == 0:
  print("Yes")
else:
  print("No")
# Original solution
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    h[0] -= 1
    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")


if __name__ == '__main__':
    main()


# Optimized solution
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').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")


if __name__ == '__main__':
    slove()
# Original solution
from itertools import chain, combinations
import copy

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


def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def is_mono(a):
    if len(a) < 2:
        return True
    for i in range(len(a) - 1):
        if a[i + 1] < a[i]:
            return False
    return True


def can_mono(a):
    for i in range(len(a) - 2):
        if a[i + 1] < a[i] and a[i + 2] < a[i + 1]:
            return False
    for m in powerset(list(range(len(a)))):
        b = copy.deepcopy(a)
        for i in m:
            b[i] -= 1
            if is_mono(b):
                return True
    return False


if can_mono(a):
    result = 'Yes'
else:
    result = 'No'
print(("{}".format(result)))

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


def can_mono(a):
    len_a = len(a)
    for i in range(len_a - 2):
        if a[i + 1] < a[i] - 1:
            return False
        if a[i + 1] < a[i]:
            for j in range(i + 1, len_a - 1):
                if a[j + 1] < a[i + 1]:
                    return False
                if a[j + 1] > a[i + 1]:
                    break
                if a[j + 1] == a[i + 1]:
                    continue
    return True


if can_mono(a):
    result = 'Yes'
else:
    result = 'No'
print(("{}".format(result)))
# Original solution
N = int(eval(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')

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

down = False
p = -1
for h in H:
    if p - h >= 2:
        print('No')
        exit()
    if down and p - h >= 1:
        print('No')
        exit()
    if p < h:
        down = False
    elif p > h:
        down = True
    p = h
print('Yes')
# Original solution
N = int(eval(input()))
H = list(map(int, input().split()))
for i in range(1, N):
    if H[i] < max(H[:i]) - 1:
        print("No")
        exit()
print("Yes")


# Optimized solution
N = int(eval(input()))
H = list(map(int, input().split()))
M = 0
for i in range(1, N):
    M = max(M, H[i - 1])
    if H[i] < M - 1:
        print("No")
        exit()
print("Yes")
# Original solution
n = int(eval(input()))

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

flag = False
length = len(h)

if length == 1:
	flag = True

for i in reversed(list(range(1,length))):
	if h[i] < h[i-1]:
		h[i-1] = h[i-1] - 1
		if h[i] != h[i-1]:
			break

	if i == 1:
		flag = True

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

# Optimized solution
import sys

n = int(eval(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
		if h[i] < h[i+1]:
			print('No')
			sys.exit()

print('Yes')
# Original solution
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    nums = list(map(int, input().split()))

    for x in reversed(list(range(1, len(nums)))):
        if nums[x-1] > nums[x]:
            nums[x-1] -= 1

        if nums[x-1] > nums[x]:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()

# Optimized solution
import sys

input = sys.stdin.readline
n = int(eval(input()))
nums = list(map(int, input().split()))
maxnum = 0

for x in nums:
    if maxnum < x:
        maxnum = x
    if maxnum - x > 1:
        print('No')
        sys.exit() 

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

if all(H[i-1] <= H[i] for i in range(1, n)):
    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
print(('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No'))