n = int(input())
h = list(map(int, input().split()))
h.reverse()
s = h[0]
z = 'Yes'
for i in range(n - 1):
    if h[i] <= s:
        s = h[i]
    elif h[i] - s == 1:
        s = s
    else:
        z = 'No'
        break
print(z)

073306d1b18f7d13269167874283ab465701c530
<mask token>

<mask token>
h.reverse()
<mask token>
for i in range(n - 1):
    if h[i] <= s:
        s = h[i]
    elif h[i] - s == 1:
        s = s
    else:
        z = 'No'
        break
print(z)

n = int(input())
h = list(map(int, input().split()))
h.reverse()
s = h[0]
z = 'Yes'
for i in range(n - 1):
    if h[i] <= s:
        s = h[i]
    elif h[i] - s == 1:
        s = s
    else:
        z = 'No'
        break
print(z)
