Everybody knows of spaghetti sort. You decided to implement an analog sorting algorithm yourself, but as you survey your pantry you realize you're out of spaghetti! The only type of pasta you have is ravioli, but you are not going to let this stop you...

You come up with the following algorithm. For each number in the array a_{i}, build a stack of a_{i} ravioli. The image shows the stack for a_{i} = 4.

 [Image] 

Arrange the stacks in one row in the order in which the corresponding numbers appear in the input array. Find the tallest one (if there are several stacks of maximal height, use the leftmost one). Remove it and add its height to the end of the output array. Shift the stacks in the row so that there is no gap between them. Repeat the procedure until all stacks have been removed.

At first you are very happy with your algorithm, but as you try it on more inputs you realize that it doesn't always produce the right sorted array. Turns out when two stacks of ravioli are next to each other (at any step of the process) and differ in height by two or more, the top ravioli of the taller stack slides down on top of the lower stack.

Given an input array, figure out whether the described algorithm will sort it correctly.


-----Input-----

The first line of input contains a single number n (1 ≤ n ≤ 10) — the size of the array.

The second line of input contains n space-separated integers a_{i} (1 ≤ a_{i} ≤ 100) — the elements of the array.


-----Output-----

Output "YES" if the array can be sorted using the described procedure and "NO" if it can not.


-----Examples-----
Input
3
1 2 3

Output
YES

Input
3
3 1 2

Output
NO



-----Note-----

In the second example the array will change even before the tallest stack is chosen for the first time: ravioli from stack of height 3 will slide on the stack of height 1, and the algorithm will output an array {2, 2, 2}.

Difficulty: introductory

Starter code:

Solutions:
"""
Codeforces April Fools 2018 Problem C

Author  : chaotic_iak
Language: Python 3.5.2
"""

################################################### SOLUTION

def initialize_solution():
    pass

def main():
    n, = read()
    a = read()
    for i in range(n-1):
        if abs(a[i] - a[i+1]) >= 2:
            return "NO"
    return "YES"

########################################## PROBLEM CONSTANTS

READ_FROM_FILE = None
OUTPUT_PREFIX = None
INTERACTIVE = False

#################################################### HELPERS

import sys

def read(callback=int, split=True):
    if READ_FROM_FILE:
        ipt = sfile.readline().strip()
    else:
        ipt = input().strip()
    if INTERACTIVE and ipt == "WRONG_ANSWER":
        return
    if split:
        return list(map(callback, ipt.split()))
    else:
        return callback(ipt)

def write(value, end="\n"):
    if value is None: return
    try:
        if not isinstance(value, str):
            value = " ".join(map(str, value))
    except:
        pass
    if READ_FROM_FILE:
        tfile.write(str(value, end=end))
    else:
        print(value, end=end)
    if INTERACTIVE:
        sys.stdout.flush()

sfile = None
tfile = None
if READ_FROM_FILE:
    sfile = open(READ_FROM_FILE + ".in", "r")
    sfile.seek(0)
    tfile = open(READ_FROM_FILE + ".out", "w")
if OUTPUT_PREFIX is None:
    result = main()
    if result is not None:
        write(result)
else:
    initialize_solution()
    TOTAL_CASES, = read()
    for CASE_NUMBER in range(1, TOTAL_CASES+1):
        write(OUTPUT_PREFIX.replace("%d", str(CASE_NUMBER)), end="")
        result = main()
        if result is not None:
            write(result)
if sfile is not None: sfile.close()
if tfile is not None: tfile.close()


n = int(input())
f = 0
a = list(map(int , input().split()))
for i in range(n - 1):
    if(abs(a[i] - a[i + 1]) > 1):
        f = 1
print(["YES" , "NO" ][f])


# -*- coding: utf-8 -*-

import math

n = int(input())
s = input().split()
for i in range(1,len(s)):
    if math.fabs(int(s[i]) - int(s[i-1])) > 1:
        print("NO")
        return

print("YES")

n = int(input())

a = list(map(int, input().split()))
for i in range(n - 1):
    if abs(a[i] - a[i + 1]) >= 2:
        print('NO')
        return
print('YES')

input()
a = list(map(int,input().split()))
s = sorted(a)
while a:
    for i in range(1,len(a)):
        if a[i] > a[i - 1] + 1 or a[i] + 1 < a[i - 1]:
            print('NO')
            return
    a.remove(max(a))
print('YES')


# A
# print(int(input()) % 2)

# C
input()
a = [int(x) for x in input().split()]
while a:
    for i in range(len(a)-1):
        if abs(a[i] - a[i+1]) >= 2:
            print('NO')
            return
    i = a.index(max(a))
    a.pop(i)
print('YES')


n = int(input())
a = list(map(int, input().split()))
f = 'YES'
for i in range(n - 1):
    if abs(a[i] - a[i + 1]) > 1:
        f = 'NO'
        break
print(f)

ooo = input()
m = [int(i) for i in input().split()]
k = False
for i in range(int(ooo)-1):
    if abs(m[i]-m[i+1]) > 1:
        print('NO')
        k = True
        break
if not k:print('YES')

def govno():
    for i in range(len(num) - 1):
        if abs(num[i] - num[i + 1]) >= 2:
            if num[i] < num[i + 1]:
                num[i + 1] -= 1
                num[i] += 1
            else:
                num[i] -= 1
                num[i + 1] += 1


n = int(input())
num = list(map(int, input().split()))
cor = []
cor += num
cor.sort()
our = []
for i in range(n):
    govno()
    a = max(num)
    num.pop(num.index(a))
    our.append(a)
our.reverse()
if our == cor:
    print('YES')
else:
    print('NO')

N = int(input())
A = list(map(int, input().split()))
ok = True
for i in range(N):
  for j in range(N - i - 1):
    if abs(A[j] - A[j + 1]) > 1:
      ok = False
  idx = A.index(max(A))
  A = A[:idx] + A[idx + 1:]
if ok:
  print('YES')
else:
  print('NO')

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

for i in range(len(a) - 1):
    if abs(a[i + 1] - a[i]) > 1:
        print('NO')
        return

while len(a) > 0:
    m = max(a)
    i = a.index(m)
    a.remove(m)
    if 0 < i < len(a) and abs(a[i] - a[i - 1]) > 1:
        print('NO')
        return

print('YES')

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

for i in range(len(a) - 1):
    if abs(a[i + 1] - a[i]) > 1:
        print('NO')
        return

print('YES')

n = int(input())
r = list(map(int, input().split(' ')))
s = []

def ok():
    prev = r[0]
    for ra in r[1:]:
        if abs(ra-prev) >= 2:
            return False
        prev = ra
    return True

while len(r):
    if not ok():
        print('NO')
        return
    
    maxi = 0
    for i in range(len(r)):
        if r[i] > r[maxi]:
            maxi = i
    r.pop(maxi)
    
print('YES')


n = int(input())
b = True
a = [int(i) for i in input().split()]
for i in range(n-1):
    if abs(a[i+1]-a[i])>=2: b = False
if b: print("YES")
else: print("NO")

n = int(input().strip())
x = list(map(int, input().strip().split()))

def check(y):
    for i in range(len(y)-1):
        if abs(y[i]-y[i+1]) > 1:
            return False
    return True

okay = True
if not check(x):
    okay = False
while len(x) > 1:
    m = max(x)
    x.remove(m)
    if not check(x):
        okay = False

print('YES' if okay else 'NO')


def check(d):
    for i in range(1, len(d)):
        if abs(d[i - 1] - d[i]) > 1:
            return 1
    return 0

n = int(input())
a = [int(i) for i in input().split()]
b = []
ans = 0
ans = ans or check(a)
for i in range(n):
    mx = max(a)
    a.pop(a.index(mx))
    b.append(mx)
    ans = ans or check(a)
ans = ans or check(b)
print(['YES', 'NO'][ans])

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


import sys
n = input()
a = [int(x) for x in input().split()]
ac = list(a)
r = []
ok = True

for i in range(len(a) - 1):
    if (abs(a[i] - a[i + 1]) >= 2):
        print ("NO")
        return
a = list(sorted(a))

for i in range(len(a) - 1):
    if (abs(a[i] - a[i + 1]) >= 2):
        print ("NO")
        return
        
print ("YES")

def is_good(xs):
    for i in range(1, len(xs)):
        if abs(xs[i] - xs[i - 1]) >= 2:
            return False
    return True


n = int(input())
xs = list(map(int, input().split()))
ok = is_good(xs) and is_good(list(sorted(xs)))
for i in range(n):
    pos = 0
    for j in range(n - i):
        if xs[j] > xs[pos]:
            pos = j
    val = xs[pos]
    xs.pop(pos)
    ok = ok and is_good(xs)
print('YES' if ok else 'NO')

n=int(input())
a=list(map(int,input().split()))
s=set()
for i in range(n-1):
    s.add(abs(a[i]-a[i+1]))
if len(list([x for x in s if x>1]))>0:print('NO')
else:print('YES')


def topple(a):
    for i in range(1, len(a)):
        if a[i] - 2 >= a[i - 1]:
            a[i] -= 1
            a[i - 1] += 1
        elif a[i] + 2 <= a[i - 1]:
            a[i - 1] -= 1
            a[i] += 1

    return a

def ravioli(a):
    res = []
    while a:
        a = topple(a)
        best = 0 
        for i in range(len(a)):
            if a[i] > a[best]:
                best = i
        res.append(a[best])
        a = a[:best] + a[best + 1:]

    return list(reversed(res))

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

c = ravioli(a)
if b == c:
    print('YES')
else:
    print('NO')



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

for i in range(n - 1):
    if abs(a[i] - a[i + 1]) > 1:
        ok = False

if ok:
    print('YES')
else:
    print('NO')


'''input
3
3 1 2
'''

def check(a):
	for i in range(len(a)-1):
		if(abs(a[i]-a[i+1]) >= 2): return False
	return True

n = int(input())
a = list(map(int,input().split()))
ans = "YES"
while(a):
	if(not check(a)):
		ans = "NO"
		break
	ind = 0
	mx = a[0]
	for i in range(1,n):
		if(a[i] > mx):
			mx = a[i]
			ind = i
	n -= 1
	del(a[ind])
print(ans)	

n = int(input())
a = [int(i) for i in input().split()]
while len(a)!=1:
    
    m = a[0]
    im = 0
    for i in range(1,len(a)):
        if abs(a[i] - a[i-1])>=2:
            print("NO")
            return
        if a[i]>m:
            m = a[i]
            im = i
    a.pop(im)
print("YES")

n = int(input())
a = list(map(int, input().split()))
b = sorted(a, reverse=True)
c = []
for i in range(n):
    for j in range(len(a) - 1):
        if a[j] > a[j + 1] + 1 or a[j] < a[j + 1] - 1:
            print('NO')
            return
    c += [max(a)]
    a.remove(max(a))
assert b == c, (b, c)
print('YES')