Array of integers is unimodal, if:  it is strictly increasing in the beginning;  after that it is constant;  after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.For example, the following three arrays are unimodal: [5, 7, 11, 11, 2, 1], [4, 4, 2], [7], but the following three are not unimodal: [5, 5, 6, 6, 1], [1, 2, 1, 2], [4, 5, 5, 6].Write a program that checks if an array is unimodal.

The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000) — the elements of the array.

Print "YES" if the given array is unimodal. Otherwise, print "NO". You can output each letter in any case (upper or lower).

NoteIn the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively).

from sys import maxsize, stdout, stdin,stderr
mod = int(1e9 + 7)
import re #can use multiple splits
def tup():return map(int,stdin.readline().split())
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return input().strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
from  math import  log2,sqrt
from collections import defaultdict
# s= S().split()
# n = I()
#
# d='^>v<'
# if n%2==0:print('undefined')
# else:
#     st =d.find(s[0]).__index__()
#     en = d[(st+n)%4]
#     if en==s[1]:print('cw')
#     elif d[(st-n)%4]==s[1]:print('ccw')
#     else:print('undefined')
#
# #when k it is even it will end up in the same position so direction can't be determined
# #
# k = I()
# n =S()
# arr = sorted(list(map(int,n)))
# cnt =sum(arr)
# ans = 0
# #print(arr,cnt)
# for i in arr:
#     if  cnt < k:
#         cnt+=9 - i
#         ans+=1
# print(ans)
# #increasing sum by 9-d

n,ls = I(),lint()
i =0
while i < n-1 and ls[i] < ls[i+1]:
    i+=1
while i < n-1 and ls[i]==ls[i+1]:
    i+=1
while i < n-1 and ls[i]>ls[i+1]:
    i+=1
if i==n-1:print("YES")
else:print("NO")

n = int(raw_input())
array = map(int, raw_input().split())

i = 0

while i < n-1 and array[i] < array[i+1]:
	i += 1
while i < n-1 and array[i] == array[i+1]:
	i += 1
while i < n-1 and array[i] > array[i+1]:
	i += 1

if i == (n - 1):
	print 'YES'
else:
	print 'NO'

import sys
n = int(input())
data = [int(x) for x in input().split()]
if len(data) > 1:
    flgVV = data[0] < data[1]
    flgVn = data[-2] > data[-1]
    if flgVV:
        i = 0
        while i < len(data) - 1 and data[i] < data[i + 1]:
            i += 1
        if i == len(data) - 1:
            print('YES')
            sys.exit()
        while i < len(data) - 1 and data[i] == data[i + 1]:
            i += 1
        if i == len(data) - 1 and not flgVn:
            print('YES')
            sys.exit()
        while flgVn and i < len(data) - 1 and data[i] > data[i + 1]:
            i += 1
        if i < len(data) - 1:
            print('NO')
            sys.exit()
        print('YES')
    else:
        i = 0
        while i < len(data) - 1 and data[i] == data[i + 1]:
            i += 1
        if i == len(data) - 1 and not flgVn:
            print('YES')
            sys.exit()
        while flgVn and i < len(data) - 1 and data[i] > data[i + 1]:
            i += 1
        if i < len(data) - 1:
            print('NO')
            sys.exit()
        print('YES')
else:
    print('YES')

n=input()
arr=map(int,raw_input().split(" "))
if(n==1):
    print 'YES'
else:
    f1,f2,f3,flag=0,0,0,0
    for i in range(1,n):
        if(arr[i]>arr[i-1]):
            if(f2==0 and f3==0):
                f1=1
            else:
                flag=1
                break
        elif(arr[i]==arr[i-1]):
            if(f3==0):
                f2=1
            else:
                flag=1
                break
        else:
            f3=1
    if(flag==0):
        print 'YES'
    else:
        print 'NO'

count = input()
chisla = [int(symbol) for symbol in input().split()]

def strictly_increasing(L):
    return all(x<y for x, y in zip(L, L[1:]))

def strictly_decreasing(L):
    return all(x>y for x, y in zip(L, L[1:]))

max_value = max(chisla)
max_indexes = [index for index in range(len(chisla)) if chisla[index] == max_value]
difference_is_one = True
for i in range(len(max_indexes)-1):
    if (max_indexes[i+1]-max_indexes[i])>1:
        difference_is_one = False
if difference_is_one and strictly_increasing(chisla[:max_indexes[0]+1]) and strictly_decreasing(chisla[max_indexes[-1]:]):
    print("YES")
else:
    print("NO")

def unimodalArray(n,x):

    estado = 1 #1: Increasing
               #2: Constant
               #3: Decreasing

    for i in range(0,n-1):
        if estado == 1:
            if x[i] == x[i+1]:
                estado = 2
            elif x[i] > x[i+1]:
                estado = 3
        elif estado == 2:
            if x[i] > x[i+1]:
                estado = 3
            elif x[i] < x[i+1]:
                return "NO"
        elif estado == 3:
            if x[i] < x[i+1] or x[i] == x[i+1]:
                return "NO"

    return "YES"

nRaw = input()
n = int(nRaw)

xRaw = input()
xStr = xRaw.split()
x = list(map(int, xStr))

print(unimodalArray(n,x))

n = int(input())
a = list(map(int,input().split()))[:n]
ch = 0
while(ch<n-1 and a[ch]<a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]==a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]>a[ch+1]):
    ch += 1
ch += 1
if(ch!=n):
    print("NO")
else:
    print("YES")

n = input()
arr = list(map(int, input().split()))
inc = False
flat = False
dec = False
o = "Yes"
for i in zip(arr, arr[1:]):
	if i[0] < i[1]:
		inc = True
		if flat or dec:
			o = "No"
			break
	elif i[0] == i[1]:
		flat = True
		if dec:
			o = "No"
	elif i[0] > i[1]:
		dec = True

print(o)

N = input()
L = map(int, raw_input().split())

solve = True

step = 1

for i in xrange(1, N):
    if step == 1:
        if L[i] > L[i - 1]:
            continue
        else:
            step = 2

    if step == 2:
        if L[i] == L[i - 1]:
            continue
        else:
            step = 3

    if step == 3:
        if L[i] < L[i - 1]:
            continue
        else:
            solve = False
            break

if solve:
    print "YES"
else:
    print "NO"

n = int(raw_input())
arr = map(int, raw_input().split())

inc = 1
constant = 2
dec = 3

for i in xrange(1, len(arr)):
    if (arr[i] > arr[i-1]):
        if (dir == constant or dir == dec):
            print "NO"
            exit(0)
        dir = inc
        continue
    if (arr[i] == arr[i-1]):
        if (dir == dec):
            print "NO"
            exit(0)
        dir = constant
        continue
    if (arr[i] < arr[i-1]):
        dir = dec
        continue
print "YES"

import itertools
import math
from collections import defaultdict

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

def solve():
    n = int(input())
    a = input_ints()
    x = 0
    while x < n - 1:
        if a[x] < a[x + 1]:
            x += 1
        else:
            break
    y = n - 1
    while y > 0:
        if a[y - 1] > a[y]:
            y -= 1
        else:
            break
    if y < x:
        print('NO')
        return
    x += 1
    for i in range(x, y):
        if a[i] != max(a):
            print('NO')
            return
    print('YES')

if __name__ == '__main__':
    solve()

def top(l2,i):
    if len(l2)==2:
        print("yes")
        exit(0)
    for j in range(i,len(l2)-1):
        if l2[j]>l2[j+1]:
            decrement(l2,j+1)
        if l2[j]<l2[j+1]:
            print("no")
            exit(0)
    print("yes")
    exit(0)
def decrement(l3,i):
    if i==len(l3)-1:
        print("yes")
        exit(0)
    for j in range(i,len(l3)-1):
        if l3[j]<=l3[j+1]:
            print("no")
            exit(0)
    print("yes")
    exit(0)
if __name__=="__main__":
    n=int(input())
    l1=list(map(int,input().split()))
    if len(l1)==1:
        print("yes")
        exit(0)
    for i in range(0,len(l1)-1):
        if l1[i]==l1[i+1]:
            top(l1,i+1)
        elif l1[i]<l1[i+1]:
            pass
        elif l1[i]>l1[i+1]:
            decrement(l1,i+1)
    print("yes")

n=input()
a=map(int,raw_input().split())
top=max(a)
t=[]
count=0
flag=0
for i in range(n):
	if a[i]==top:
		t.append(i)
		count+=1
for i in range(t[0]):
	if i+1<=t[0]:
		if a[i]>=a[i+1]:
			flag=1
for i in range(t[0],t[count-1]+1):
	if a[i]!=top:
		flag=1
for i in range(t[count-1]+1,n):
	if i+1<n:
		if a[i]<=a[i+1]:
			flag=1
if flag==1:
	print 'NO'
else:
	print 'YES'

def main():
    size = int(input())
    array = [int(x) for x in input().split(' ')]
    has_constant = False
    has_fall = False

    for i in range(len(array) - 1):
        a, b = array[i], array[i + 1]
        if a < b and not has_fall and not has_constant:
            continue
        if a > b:
            has_fall = True
            continue
        if a == b and not has_fall:
            has_constant = True
            continue
        return 'NO'
    return 'YES'

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

"""def main():
    first_keys = [x for x in input()]
    second_keys = [x for x in input()]
    wrong_text = [x for x in input()]
    result = []

    for character in wrong_text:
        result.append(second_keys[first_keys.index(character)])
    return ''.join(result)
"""

R= lambda: map(int,input().split())
n=int(input())
l=list(R())
i,s1,s2,s3=1,0,0,0
while i<n and l[i]>l[i-1]:  i+=1
s1=i-1
while i<n and l[i]==l[i-1]: i+=1
s2=i-s1
while i<n and l[i]<l[i-1]:  i+=1
s3=i-(s2+s1)
if s1+s2+s3==n:     print("YES")
else:   print("NO")

def unimodal(a, lst):
    i = 1
    for i in range(i, a):
        if not (lst[i - 1] < lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] == lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] > lst[i]):
            return "NO"
    else:
        return "YES"

if __name__ == '__main__':
    a, lst = int(input()), input().split()
    lst = [int(ch) for ch in lst]
    print(unimodal(a, lst))

def get(l):
    z=l[0]
    flag=0
    for i in l[1:]:
        if i-z>0 and flag==0:
            flag = 0
        elif i-z==0 and flag<=1:
            flag = 1
        elif i-z<0 and flag<=2:
            flag =2

        else:
            return 'NO'

        z = i
    return 'YES'

_ = input()
l = list(map(int,input().split()))
print(get(l))

def main():
    read = lambda: tuple(map(int, input().split()))
    n = read()[0]
    l = read()
    if len(l) == 1:
        return "YES"
    lv = l[0]
    ss = []

    for v in l[1:]:
        state = "inc" if v > lv else "dec" if v < lv else "norm"
        if len(ss) == 0:
            if state == "dec":
                ss += ["norm"]
            ss += [state]
        elif ss[-1] != state:
            if ss[-1] == "inc" and state == "dec":
                ss += ["norm"]
            ss += [state]
        lv = v

    for state in ('inc', 'dec', 'norm'):
        if ss.count(state) > 1:
            return "NO"
    if len(ss) == 1:
        return "YES"
    if len(ss) == 2:
        return "YES" if ss == ["norm", "dec"] or ss == ["inc", "norm"] else "NO"
    return "YES" if ss == ['inc', 'norm', 'dec'] else "NO"
print(main())

n=int(input())
l=list(map(int,input().split()))
p=0
c=-1
r=-1
p1=0
for i in range(1,n) :
    if l[i]>l[i-1] and r==-1  :
        p=0
    else :
        if r==-1 :
            r=l[i]
        else :
            if l[i]!=r and r<l[i] :
                print('NO')
                exit()
        if l[i]<l[i-1] :
            c=i+1
            break
if c!=-1 :
    for i in range(c,n) :
        if l[i-1]<=l[i] :
            print('NO')
            exit()
print('YES')

import sys
n = int(input())
arr = list(map(int,input().split()))
s = ''
pre = arr[0]
for i in range(1,n):
    if( pre < arr[i] ):
        if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'i')):
            s += 'i'
    elif( pre == arr[i] ):
        if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'c')):
            s += 'c'
    elif( pre > arr[i] ):
        if(len(s) == 0 or ( len(s) > 0 and s[-1] != 'd')):
            s += 'd'
    pre = arr[i]
#print(s)
if( n == 1 or s == 'icd' or s == 'c' or s == 'i' or s == 'd' or s == 'ic' or s == 'cd' or s == 'id'):
    print('YES')
else:
    print('NO')

n = int(input())
arr = list(map(int, input().split(" ")))
j=0
while (j < n-1 and arr[j] < arr[j+1]):
	j=j+1
while (j < n-1 and arr[j] == arr[j+1]):
	j=j+1
while (j < n-1 and arr[j] > arr[j+1]):
	j=j+1
if j == n-1:
	print("Yes")
else:
	print("No")

#!usr/bin/python 3

def main():
    a=int(input())
    lst=input().split(' ')
    lst=[int(x) for x in lst]
    state=0
    prev=0
    printed=False
    for x in range(0,a):
        if state==0:

            if lst[x]==prev:
                state=1
            elif lst[x]<prev:
                state=2
            prev=lst[x]
        elif state==1:
            if lst[x]>prev:
                printed=True
                print('NO')
                break
            elif lst[x]<prev:
                state=2
            prev=lst[x]
        elif state==2:
            if lst[x]>=prev:
                printed=True
                print('NO')
                break
            prev=lst[x]

    if printed==False:
        print('YES')

if __name__=='__main__':
    main()

n = input()
arr = map(int, raw_input().split(' '))
blocks = []

if len(arr) == 1:
    print('YES')
else:

    for i in range(1, n):

        diff = arr[i] - arr[i-1]
        if diff > 0:
            block = '+'
        elif diff == 0:
            block = '='
        else:
            block = '-'

        if len(blocks) > 0:
            if blocks[-1] != block:
                blocks.append(block)
        else:
            blocks.append(block)

    status = ''.join(blocks)
    if status == '+=-' or status == '=' or status == '+=' or status == '=-' or status == '+-' or status == '+' or status == '-':
        print('YES')
    else:
        print('NO')

#!/usr/bin/env python3
def solve():
    n = get(int)
    ar = get([int])
    start = -inf
    i = 1
    while i < n and ar[i] > ar[i-1]:
        i += 1

    while i < n and ar[i] == ar[i-1]:
        i += 1

    while i < n and ar[i] < ar[i-1]:
        i += 1

    if i == n:
        return 'YES'
    else:
        return 'NO'

_testcases = """
6
1 5 5 5 4 2

YES

5
10 20 30 20 10

YES

4
1 2 1 2

NO

7
3 3 3 3 3 3 3

YES

""".strip()

# ======================= B O I L E R P L A T E ======================= #
# Practicality beats purity

import re
import sys
import math
import heapq
from heapq import heapify, heappop, heappush
import bisect
from bisect import bisect_left, bisect_right
import operator
from operator import itemgetter, attrgetter
import itertools
import collections

inf = float('inf')
sys.setrecursionlimit(10000)

def tree():
    return collections.defaultdict(tree)

def cache(func):  # Decorator for memoizing a function
    cache_dict = {}

    def _cached_func(*args, _get_cache=False):
        if _get_cache:
            return cache_dict
        if args in cache_dict:
            return cache_dict[args]
        cache_dict[args] = func(*args)
        return cache_dict[args]
    return _cached_func

def equal(x, y, epsilon=1e-6):
    # https://code.google.com/codejam/kickstart/resources/faq#real-number-behavior
    if -epsilon <= x - y <= epsilon:
        return True
    if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
        return False
    return (-epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon)

def get(_type):  # For easy input
    if type(_type) == list:
        if len(_type) == 1:
            _type = _type[0]
            return list(map(_type, input().strip().split()))
        else:
            return [_type[i](inp) for i, inp in enumerate(input().strip().split())]
    else:
        return _type(input().strip())

if __name__ == '__main__':
    print(solve())

a, lst = int(input()), input().split()
lst = [int(ch) for ch in lst]

def is_modal(a, lst):
    i = 1
    for i in range(i, a):
        if not (lst[i - 1] < lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] == lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] > lst[i]):
            return "NO"
    else:
        return "YES"

print(is_modal(a, lst))

n = int(raw_input())
a = map(int,raw_input().split())
check = [0,0,0]
for i in range(1,n):
    if (a[i]>a[i-1] and (check[2]==1 or check[1]==1)) :
        print "NO"
        break
    elif (a[i]==a[i-1] and check[2]==1):
        print "NO"
        break
    elif (a[i]>a[i-1]) :
        check[0] = 1
    elif (a[i]==a[i-1]) :
        check[1] = 1
    elif (a[i]<a[i-1]) :
        check[2] = 1
else :
    print "YES"

from sys import stdin
n = int(stdin.readline().strip())
a = stdin.read().split()
a = map(int, a)
if n <= 2: print "YES"
else:
	i = 1
	while i < n and a[i] > a[i-1]: i += 1
	while i < n and a[i] == a[i-1]: i += 1
	while i < n and a[i] < a[i-1]: i += 1
	print "NO" if i < n else "YES"

__author__ = 'Esfandiar'
n = int(input())
a = list(map(int,input().split()))
f = 0
for i in range(1,n):
    if f == 0:
        if a[i] <= a[i-1]:
            f = 1
        con = a[i-1]
    else:
        if a[i] > a[i-1]:
            print('NO')
            exit()
        elif a[i] == a[i-1]:
            if a[i] != con:
                print('NO')
                exit()

print("YES")

def unimodal(arr):
    state = 0
    for i in range(0, len(arr)-1):
        if(arr[i] < arr[i+1] and (state==0)):
            state = 0
        elif(arr[i] == arr[i+1] and(state==0 or state==1)):
            state=1
        elif(arr[i] > arr[i+1]):
            state=2
        else:
            return "NO"
            break
    return "YES"
input()
print(unimodal([int(x) for x in input().split()]))

import sys
if __name__ == "__main__":
    n = input()
    last_minus = "-"
    arrs = raw_input().split(" ")
    last_element = int(arrs[0])
    res = "YES"
    for i in arrs[1:]:
        int_i = int(i)
        if last_element > int_i:
            now_minus = 1
        elif last_element == int_i:
            now_minus = 0
        else:
            now_minus = -1
        if last_minus != "-" and now_minus < last_minus:
            res =  "NO"
            break
        last_minus = now_minus
        last_element = int_i
    print res

def is_unimodal(seq):
    i = 1
    end = len(seq)
    while i < end and seq[i - 1] < seq[i]:
        i += 1
    while i < end and seq[i - 1] == seq[i]:
        i += 1
    while i < end and seq[i - 1] > seq[i]:
        i += 1
    return i == end

n = input()

arr = map(int, raw_input().split())
k = is_unimodal(arr)

if k:
	print "YES"
else:
	print "NO"

N = input()
L = map(int, raw_input().split())

solve = True

step = 1

for i in xrange(1, N):
    if step == 1:
        if L[i] > L[i - 1]:
            continue
        else:
            step = 2

    if step == 2:
        if L[i] == L[i - 1]:
            continue
        else:
            step = 3

    if step == 3:
        if L[i] < L[i - 1]:
            continue
        else:
            solve = False
            break

if solve:
    print "YES"
else:
    print "NO"

n = int(input())
l = list(map(int, input().split(" ")))
center = max(l)

inc = False
middle = False
dec = False
flag = False
for i in range(n-1):
    if l[i] == l[i+1] and l[i] == center:
        middle = True
        continue
    if l[i] <= l[i+1] and middle:
        print("NO")
        flag = True
        break
    if l[i] == center:
        middle = True
    if l[i] >= l[i+1] and not middle:
        print("NO")
        flag = True
        break
if not flag:
    print("YES")

n=int(input())
x = list(map(int, input().split(" ")))
i,j=1,n-1
while i<n and x[i]>x[i-1]:i+=1
while j>0 and x[j]<x[j-1]:j-=1
if len(set(x[i-1:j+1]))==1:
    print("YES")
else:print("NO")

input()
arr = [int(i) for i in input().split()]

mode = -1
could = True
i = 0

while i < len(arr) - 1:
    if mode == -1:
        if arr[i] < arr[i+1]: i += 1
        else: mode += 1

    elif mode == 0:
        if arr[i] == arr[i+1]:

            i += 1
        else:
            if arr[i] < arr[i+1]:
                could = False
                break
            mode += 1

    else:
        if arr[i] > arr[i+1]: i += 1
        else:
            could = False
            break

print("YES" if could else "NO")

from sys import stdin

n = int(stdin.readline().strip())
a = map(int, stdin.readline().strip().split())

i = 1
while i < n and a[i] > a[i-1]:
    i += 1

while i < n and a[i] == a[i-1]:
    i += 1

while i < n and a[i] < a[i-1]:
    i += 1

if i < n:
    print 'NO'
    quit()

print 'YES'

num, arr = int(input()), input().split()
arr = [int(x) for x in arr]

def problem8(num,arr):
    i = 1
    for i in range(i, num):
        if not (arr[i - 1] < arr[i]):
            break
    else:
        return "YES"

    for i in range(i, num):
        if not (arr[i - 1] == arr[i]):
            break
    else:
        return "YES"

    for i in range(i, num):
        if not (arr[i - 1] > arr[i]):
            return "NO"
    else:
        return "YES"

print(problem8(num,arr))

import sys
nu = input()
m = [int(i) for i in input().split()]
if len(m) == 1:
    print('YES')
    sys.exit()

prev_ind = 1
prev = m[0]
ind = lambda x, y: int((y-x)/abs(y-x)) if y != x else 0

for i in m[1:]:
    if ind(prev, i) <= prev_ind:
        prev_ind = ind(prev, i)
        prev = i
    else :
        print('NO')
        sys.exit()
print('YES')

n = int(raw_input())
l = map(int,raw_input().split())
last = l[0]
eq = False
dec = False
i = 1
while i < n:
    current = l[i]
    if current > last:
       if eq or dec:
           print "NO"
           break
    if current == last:
        eq = True
        if dec:
            print "NO"
            break
    if current < last:
        dec = True
    last = current
    i += 1
else:
    print "YES"

pattern1=["constant"]
pattern2=["constant","down"]
pattern3=["up","constant"]
pattern4=["up","constant","down"]
pattern5=["up","down"]
patternList=[str(pattern1),str(pattern2),str(pattern3),str(pattern4),str(pattern5)]

n=input()
array = [int(x) for x in raw_input().split(" ")]
pattern=[]

for idx in range(len(array)-1):
	currentPattern=None
	if array[idx+1]>array[idx]:
		currentPattern="up"
	if array[idx+1]<array[idx]:
		currentPattern="down"
	if array[idx+1]==array[idx]:
		currentPattern="constant"
	if idx==0 or (len(pattern)>0 and pattern[-1]!=currentPattern):
		pattern.append(currentPattern)

if len(pattern)==1 or len(array)==1 or (str(pattern) in patternList):
	print ("YES")
else:
	print ("NO")

n = input()
q = map(int, raw_input().split())
q = [-1000] + q + [-1000]
d = map(lambda x: 1 if x[1]>x[0] else -1 if x[1]<x[0] else 0, zip(q[:-1], q[1:]))
r = []
l = -2
for i in d:
	if i != l: r.append(i)
	l = i
if r == [1,0,-1] or r == [1,-1]:
	print 'YES'
else:
	print 'NO'

x = int(input())
nums = list(map(int, input().split()))
i = 1
while(i<x and nums[i-1] < nums[i]):
  i+=1
while(i<x and nums[i-1] == nums[i]):
  i+=1
while(i<x and nums[i-1] > nums[i]):
  i+=1

if(i==x):
  print("YES")
else:
  print("NO")

n = input()
arr = [int(x) for x in raw_input().split()]

b = 0
cv = 0
for i in range(n-1):
    ov = 0
    if arr[i] == arr[i+1]:
        ov = 1
    elif arr[i] > arr[i+1]:
        ov = 2

    if ov < cv:
        b = -1
    cv = ov

print "NO" if b == -1 else "YES"

n=input()
s=raw_input().split()
a=[0 for i in range(1005)]
c1=0
p=-1
c2=0
for i in range(n):
    a[i]=int(s[i])
for i in range(1,n):
    if a[i]==a[i-1]:
        if c1==0:
            c1=1
            p=i
        else:
            if a[i]!=a[p]:
              print "NO"
              exit()
if p==-1:
    t=0
    while t<n and a[t]<a[t+1]:
        t=t+1
    for i in range(t,n):
        if a[i]<a[i+1]:
            print "NO"
            exit()
    print"YES"
    exit()
for i in range(p):
    if a[i]>a[i+1]:
        print "NO"
        exit()
for i in range(p,n):
    if a[i]<a[i+1]:
        print "NO"
        exit()
print "YES"

def unimodal(a, lst):
    i = 1
    for i in range(i, a):
        if not (lst[i - 1] < lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] == lst[i]):
            break
    else:
        return "YES"

    for i in range(i, a):
        if not (lst[i - 1] > lst[i]):
            return "NO"
    else:
        return "YES"

if __name__ == '__main__':
    a, lst = int(input()), input().split()
    lst = [int(ch) for ch in lst]
    print(unimodal(a, lst))

# in_x = input().split(" ")
#
# a, b = int(in_x[0]), int(in_x[1])
# while a != 0 and b != 0:
#     if a >= 2 * b:
#         a = a % (2 * b)
#         continue
#     elif b >= 2 * a:
#         b = b % (2 * a)
#         continue
#     else:
#         break
# print(a, b)
# s, v1, v2, t1, t2 = [int(x) for x in input().split(" ")]
#
# first = t1 + t1 + (s * v1)
# second = t2 + t2 + (s * v2)
# if first < second:
#     print("First")
# elif first > second:
#     print("Second")
# else:
#     print("Friendship")

length = int(input())
vals = [int(x) for x in input().split(" ")]

increasing = 0
constant = 1
decreasing = 0
failed = False
for i in range(length - 1):
    if vals[i + 1] > vals[i]:
        if decreasing == 1:
            failed = True
        if increasing == 2:
            failed = True
            break
        else:
            increasing = 1
            continue
    if vals[i + 1] == vals[i]:
        if decreasing == 1:
            failed = True
            break
        increasing = 2
        constant = 1
        continue
    if vals[i + 1] < vals[i]:
        if constant == 0:
            failed = True
        decreasing = 1
        constant = 2
        continue

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

def udimol(a):
    last = a[0]
    status = 0
    for x in a[1:]:
        if status == 0:
            if x == last:
                status = 1
            elif x > last:
                pass
            else:
                status = 2
            last = x
        elif status == 1:
            if x < last:
                status = 2
                last = x
            elif x == last:
                last = x
            else:
                return 'NO'
        else:
            if x < last:
                last = x
            else:
                return 'NO'

    return 'YES'

raw_input()
s = [int(x) for x in raw_input().split(' ')]
print udimol(s)

n = int(input())
string = input()
numbers = list(map(int, string.split()))
results = "NO"
a, b = numbers[:-1], n
for x in range(n - 1):
    if not numbers[x] < numbers[x + 1]:
        a = numbers[x]
        b = x
        break
c = n
for x in range(b, n):
    if not numbers[x] == a:
        c = x
        d = numbers[x]
        break
results = "YES"
if c != n:
    if numbers[c] < a:
        for x in range(c, n - 1):
            if not numbers[x] > numbers[x + 1]:
                results = "NO"
                break
    else:
        results = "NO"
print(results)

n = int(input())
a = list(map(int,input().split()))
i = 0
j = n-1
while i+1<n and a[i]<a[i+1]:
	i+=1
while j-1>=0 and a[j-1]>a[j]:
	j-=1
if len(set(a[i:j+1]))==1:
	print("YES")
else:
	print("NO")

import itertools
import math
from collections import defaultdict

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

def solve():
    n = int(input())
    a = input_ints()
    x = 0
    while x < n - 1:
        if a[x] < a[x + 1]:
            x += 1
        else:
            break
    y = n - 1
    while y > 0:
        if a[y - 1] > a[y]:
            y -= 1
        else:
            break
    if y < x:
        print('NO')
        return
    x += 1
    for i in range(x, y):
        if a[i] != max(a):
            print('NO')
            return
    print('YES')

if __name__ == '__main__':
    solve()

n = input()
A = map(int, raw_input().split())
i=0
while i<(n-1) and A[i] < A[i+1]:
	i = i + 1
while i<(n-1) and A[i] == A[i+1]:
	i = i + 1
while i<(n-1) and A[i] > A[i+1]:
	i = i + 1
if i == (n-1):
	print "YES"
else:
	print "NO"

n = input()
array = list(map(int, input().split()))
if array.__len__() == 1:
    print("YES")
    exit(0)
i = 0
if array[i] < array[i + 1]:
    while i < array.__len__() - 1 and array[i] < array[i + 1]:
        i += 1
    if i == array.__len__() - 1:
        print("YES")
        exit(0)
if array[i] >= array[i + 1]:
    if i == array.__len__() - 2:
        print("YES")
        exit(0)
    else:
        if array[i] == array[i+1]:
            while i < array.__len__() - 1 and array[i] == array[i + 1]:
                i += 1
            if i == array.__len__() - 1:
                print("YES")
                exit(0)
            elif array[i] > array[i+1]:
                while i < array.__len__() - 1 and array[i] > array[i + 1]:
                    i += 1
                if i == array.__len__() - 1:
                    print("YES")
                else:
                    print("NO")
            else:
                print("NO")
        else:
            if i == array.__len__() - 1:
                print("YES")
                exit(0)
            else:
                while i < array.__len__() - 1 and array[i] > array[i + 1]:
                    i += 1
                if i == array.__len__() - 1:
                    print("YES")
                else:
                    print("NO")

else:
    print("NO")
    exit(0)

import sys
n = int(raw_input())

arr = map(int, raw_input().split())

m = max(arr)
x1 = -1
x2 = -1
for i in range(n):
    if arr[i] == m:
        x2 = i
        if x1 == -1:
            x1 = i

for i in range(x1,x2+1):
    if arr[i] != m:
        print "NO"
        sys.exit(0)

for i in range(x1):
    if arr[i] >= arr[i+1]:
        print "NO"
        sys.exit(0)

for i in range(x2, n-1):
    if arr[i] <= arr[i+1]:
        print "NO"
        sys.exit(0)

print "YES"

n=int(input())
arr=list(map(int,input().split()))
diff=[]
for i in range(1,n):
    if arr[i]-arr[i-1]>0:
        diff.append(1)
    elif arr[i]-arr[i-1]==0:
        diff.append(0)
    else:
        diff.append(-1)

op=diff[:]
diff.sort(reverse=True)
if op==diff:
    print('YES')
else:
    print('NO')

import sys

it = iter(sys.stdin.read().splitlines())

largo = int(next(it))
lista = [int(x) for x in next(it).split()]

i = 0

while(i<largo-1) and (lista[i]<lista[i+1]):
    i += 1
while(i<largo-1) and (lista[i]==lista[i+1]):
    i += 1
while(i<largo-1) and (lista[i]>lista[i+1]):
    i += 1

if(i == largo-1):
    print("YES")
else:
    print("NO")

n=int(input())
l=[int(x) for x in input().split()]
i=0
while i<(n-1) and l[i]<l[i+1]:
    i+=1
while i<n-1 and l[i]==l[i+1]:
    i+=1
while i<n-1 and l[i]>l[i+1]:
    i+=1
if i==n-1:
    print("YES")
else:
    print("NO")

from itertools import groupby
import sys
n = int(raw_input().strip())
A = map(int, raw_input().strip().split())
if n==1:
    print "YES"
    sys.exit()
s = ""
for a0 in range(1, len(A)):
    if A[a0] - A[a0-1] >0:
        s+='1'
    elif A[a0] ==A[a0-1]:
        s+='2'
    else:
        s+='3'
#print s
list_s = list(s)
s = "".join([a[0] for a in groupby(list_s)])
#print s
if s == "123":
    print "YES"
elif s=="1" or s=="2" or s=="3":
    print "YES"
elif s=="12" or s=="13" or s=="23":
    print "YES"
else:
    print "NO"

def unimodal():
    import sys
    nList = []
    count = 0
    N = int(input())
    S = input()
    nList = S.split()
    nList = [int(i) for i in nList]
    for x in range(len(nList)-2):
        if (nList[x+1] - nList[x] > 0): #증가구간
            pass
        else:
            if (nList[x+1] - nList[x] == 0): #유지구간
                if (nList[x + 2] - nList[x + 1] > 0):
                    print("NO")
                    sys.exit()
                pass
            else:
                if (nList[x+1] - nList[x] < 0): #감소구간
                    if (nList[x + 2] - nList[x + 1] > 0):
                        print("NO")
                        sys.exit()
                    elif (nList[x + 2] - nList[x + 1] == 0):
                        print("NO")
                        sys.exit()
                pass
    print("YES")

unimodal()

import sys

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

ch = True
if( n == 1 ):
    print 'YES'
else:
    i = 0
    while( a[i] < a[i + 1] ):
        i += 1
        if( i == n - 1 ):
            break
    if( i < n - 1 ):
        while( a[i] == a[i + 1] ):
            i += 1
            if( i == n - 1 ):
                break
        for j in range(i, n - 1):
            if( a[j] <= a[j + 1] ):
                print 'NO'
                ch = False
                break
    if( ch == True ):
        print 'YES'

raw_input()
vals = map(int, raw_input().split())

phase = 0
res = True

for i in range(1, len(vals)):
    if vals[i-1] < vals[i]:
        if phase != 0:
            res = False
    if vals[i-1] == vals[i]:
        if phase == 0:
            phase = 1
        if phase != 1:
            res = False
    if vals[i-1] > vals[i]:
        if phase <= 1:
            phase = 2
        if phase != 2:
            res = False

if res:
    print "YES"
else:
    print "NO"

curP = 0

input()

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

f= True
for i in range(1, len(A)):
    if A[i] > A[i-1] and (curP == 1 or curP == 2):
        f = False
        break

    elif A[i] == A[i-1] and (curP == 2):
        f = False
        break

    elif A[i] == A[i-1]:
        curP = 1

    elif A[i] < A[i-1]:
        curP = 2

if f:
    print("YES")
else:
    print("NO")

INCREASING = 0
DECREASING = 1
EQUAL = 2

n = int(raw_input())
array = map(int, raw_input().split())

state = INCREASING
res = True
begin = True

if len(array) > 0:
    prev = array[0]

for i in array:
    if i > prev:
        if state != INCREASING:
            res = False
            break

    if i < prev:
            state = DECREASING

    if i == prev and not begin:
        if state == DECREASING:
            res = False
            break
        state = EQUAL

    begin = False
    prev = i

print 'YES' if res else 'NO'

n=input()
inp=input().split()
mark1=0
mark2=0
judge=0
num=int(inp[0])

for i in range(1,int(n)):
    if int(inp[i])>num:
        num=int(inp[i])
        if mark1==1 or mark2==1:
            judge=1
            break
    elif int(inp[i])==num :
        mark1=1
        if mark2==1:
            judge=1
            break
    else:
        num=int(inp[i])
        mark2=1

if judge==0:
    print("YES")
else:
    print("NO")

from sys import stdin
input = lambda :stdin.readline().strip()

n = int(input())
a = [*map(int, input().split())]

state = None
answer = "YES"
for i in range(1, n):
	if state == None:
		if a[i] == a[i-1]:
			state = "sam"
		elif a[i] < a[i-1]:
			state = 'dec'
		else:
			state = 'inc'
	if state == 'dec':
		if a[i] == a[i-1]:
			answer = 'NO'
		elif a[i] > a[i-1]:
			answer = "NO"
		else:
			continue
	if state == 'sam':
		if a[i] == a[i-1]:
			continue
		elif a[i] > a[i-1]:
			answer = 'NO'
			break
		else:
			state = 'dec'
	if state == 'inc':
		if a[i] == a[i-1]:
			state = "sam"
		elif a[i] > a[i-1]:
			continue
		else:
			state = 'dec'
print(answer)

n = int(input())

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

if len(set(t))==1:
    print('YES')
elif t == sorted(t) and len(set(t))==n:
    print('YES')
elif t == sorted(t)[::-1] and len(set(t))==n:
    print('YES')
else:

    u = max(t)

    x=t.index(u)
    h=0
    for j in range(1,x):
        if t[j]>t[j-1]:
            pass
        else:
            print('NO')
            h+=1
            break
    if h==0:
        for y in range(x+t.count(u),n):
            if t[y]<t[y-1]:
                pass
            else:
                print('NO')
                h+=1
                break

        if h==0:
            print('YES')

n = int(raw_input())
a = map(int, raw_input().split())
ans = "YES"
if len(a) > 2:
  cs = a[0] - a[1]
  for i in range(1, n-1):
    if cs < 0:
      if a[i+1] < a[i]:
        cs = 1
      elif a[i+1] == a[i]:
        cs = 0
    elif cs == 0:
      if a[i+1] > a[i]:
        ans = "NO"
        break
      elif a[i+1] < a[i]:
        cs = 1
    elif a[i+1] >= a[i]:
        ans = "NO"
        break
print ans

import sys
import math

def readArray():return map(int,sys.stdin.readline().split())
def readString():return sys.stdin.readline().strip()
def readNum():return readString()
def exp(t,x):
   MOD=1000000007
   if(x==0):return 1
   if(x==1):return t
   if(x%2==1):return exp((t*t)%MOD,x/2)
def gcd(x,y):
   if x%y==0:return y
   else: return gcd(y,x%y)
def lcm(x,y):return x*(y/gcd(x,y))
def isprime(x):
   i=2
   while (i*i<=x):
      	if (x%i==0):return False
	i+=1
   return True

n=readNum()
n=int(n)
a=readArray()

ind=0
while ind<n-1 and a[ind]<a[ind+1]:ind+=1
while ind<n-1 and a[ind]==a[ind+1]:ind+=1
while ind<n-1 and a[ind]>a[ind+1]:ind+=1

if ind==n-1:
  print 'YES'
else:
  print 'NO'

n=int(input())
arr=list(map(int,input().split()))
pos1,pos2=0,n-1
for i in range(n-1):
    if arr[i+1]>arr[i]:
        pos1+=1
    else:
        break

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

check=1
for i in range(pos1,pos2):
    if not arr[i]==arr[i+1]:
        check=0
        break
if check==1:
    print("yes")
else:
    print("no")

def Unimodal():
    n = int(raw_input())
    array = list(map(int,raw_input().split()))

    if array.count(array[0]) == n:
        return 'YES'
    else:
        current = array[0]
        i = 1
        while i < n:
            if array[i] > current:
                current = array[i]
                i += 1
            else:
                break
        while i < n:
            if array[i] == current:
                current = array[i]
                i += 1
            else:
                break
        while i < n:
            if array[i] < current:
                current = array[i]
                i += 1
            else:
                break
        if i == n:
            return 'YES'
        else:
            return 'NO'

print Unimodal()

R= lambda: map(int,input().split())
n=int(input())
l=list(R())
i,s1,s2,s3=1,0,0,0
while i<n and l[i]>l[i-1]:  i+=1
s1=i-1
while i<n and l[i]==l[i-1]: i+=1
s2=i-s1
while i<n and l[i]<l[i-1]:  i+=1
s3=i-(s2+s1)
if s1+s2+s3==n:     print("YES")
else:   print("NO")

n = int(input())
a = list(map(int,input().split()))[:n]
ch = 0
while(ch<n-1 and a[ch]<a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]==a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]>a[ch+1]):
    ch += 1
ch += 1
if(ch!=n):
    print("NO")
else:
    print("YES")

n = int(input())
a = list(map(int,input().split()))
flag = True
f =f3 = True
for i in range(1,n):
	if flag==True:
		if a[i]==a[i-1]:
			flag = False
			prev = a[i-1]
		elif a[i]<a[i-1]:
			flag = False
			f3 = False
	else:
		if f3==True and a[i]==prev:
			f = True
		else:
			f3 = False
			if a[i]>=a[i-1]:
				f = False
				break
if f==True:
	print("YES")
else:
	print("NO")

n=input()
a=map(int,raw_input().split())
top=max(a)
t=[]
count=0
flag=0
for i in range(n):
	if a[i]==top:
		t.append(i)
		count+=1
for i in range(t[0]):
	if i+1<=t[0]:
		if a[i]>=a[i+1]:
			flag=1
for i in range(t[0],t[count-1]+1):
	if a[i]!=top:
		flag=1
for i in range(t[count-1]+1,n):
	if i+1<n:
		if a[i]<=a[i+1]:
			flag=1
if flag==1:
	print 'NO'
else:
	print 'YES'

n=int(input())
a=map(int,raw_input().split())
i=0
j=n
while i+1<n and a[i]<a[i+1]:
	i=i+1
while j>0 and a[j-2]>a[j-1]:
	j=j-1
b=set(a[i:j])
print 'YES' if len(b)<2 else 'NO'

import sys
n = int(raw_input().strip())
ar = map(int, raw_input().strip().split(' '))
i=0
while (i<n-1 and ar[i]<ar[i+1]):
	i=i+1
while (i<n-1 and ar[i]==ar[i+1]):
	i=i+1
while (i<n-1 and ar[i]>ar[i+1]):
	i=i+1
if i==n-1:
	print 'YES'
else:
	print 'NO'

#!usr/bin/env python

n=input()
a=map(int,raw_input().split())
i,j=0,n
while i+1<n and a[i]<a[i+1]:
  i+=1
while j>1 and a[j-1]<a[j-2]:
  j-=1
b=set(a[i:j])
print 'YES' if len(b)<2 else 'NO'

n=input()
a=map(int,raw_input().split())
i,j=0,n
while i+1<n and a[i]<a[i+1]:
  i+=1
while j>1 and a[j-1]<a[j-2]:
  j-=1
b=set(a[i:j])
print 'YES' if len(b)<2 else 'NO'

# -*- coding: utf-8 -*-
"""
Created on Wed Jul 26 15:08:27 2017

@author: WalkingDeada

Don't lose your heart
"""

n=int(input())
a=map(int,raw_input().split())
i=0
j=n
while i+1<n and a[i]<a[i+1]:
    i+=1
while j>0 and a[j-2]>a[j-1]:
    j-=1
b=set(a[i:j])
print 'YES' if len(b)<2 else 'NO'

n = int(input())
a = list(map(int, input().split()))
b = 0
c = 0
d = 0
for i in range(n-1):
    if(a[i] < a[i+1] and b == 0 and d == 0):
        continue
    elif(a[i] == a[i+1] and b == 0):
        d = 1
        continue
    elif(a[i] > a[i+1] and b == 0 and d == 1):
        b = 1
    else:
        if(a[i] < a[i+1] and (b == 1 or d == 1)):
            c = 1
            break
        elif(a[i] == a[i+1] and b == 1):
            c = 1
            break
        else:
            b = 1
if(c == 1):
    print("NO")
else:
    print("YES")

def check(c):
    combs = [["i", "c", "d"], ["c"], ["c", "d"], ["i", "c"], ["i", "d"], ["i"], ["d"]]
    if removeNeighbours(list(c)) in combs: return True
    return False

def removeNeighbours(l):
    i = 0
    while i < len(l) - 1:
        if l[i] == l[i + 1]:
            del l[i]
        else:
            i = i + 1
    return l

def solve(a):
    c = ""

    for i in range(len(a) - 1):
        if a[i] < a[i + 1]:
            c += "i"
        elif a[i] == a[i + 1]:
            c += "c"
        elif a[i] > a[i + 1]:
            c += "d"

    if len(a) == 1:
        return True
    elif check(c):
        return True
    return False

N = int(input())
A = [int(i) for i in input().split()]
print("YES" if solve(A) else "NO", end="")
# 1521989021332

n = int(input())
a = list(map(int, input().split(' ')))
l1 = 0; l2 = n-1
while l1<n-1 and a[l1+1]>a[l1]: l1 += 1
while l2>0 and a[l2-1]>a[l2]: l2 -= 1
x = a[l2]
ans = "YES"
for i in range(l1,l2):
    if a[i] != x: ans = "NO"; break
print(ans)

n=int(input())
a=[int(x) for x in input().split()]
wasc=wcon=wdes=False
uni=True
for x in range(1,n):
	if(a[x] > a[x-1]):
		wasc=True
		if(wdes or wcon):
			uni=False
			break
		continue
	else:
		if(a[x] == a[x-1]):
			wcon=True
			if(wdes):
				uni=False
				break
			continue
		else:
			if(a[x] < a[x-1]):
				wdes=True
				continue
if(uni):print("YES")
else:print("NO")

n = int(input())
arr = list(map(int,input().split()))
arr.append(-100000000000)
arr.append(1000000000000)
i = 0
while(arr[i] < arr[i+1] and i < n-1):
	i = i + 1

while(arr[i] == arr[i+1] and i < n-1):
	i = i + 1

while(arr[i] > arr[i+1] and i < n-1):
	i = i + 1

if(i == n-1):
	print("YES")

else:
	print("NO")

import sys

it = iter(sys.stdin.read().splitlines())

largo = int(next(it))
lista = [int(x) for x in next(it).split()]

i = 0

while(i<largo-1) and (lista[i]<lista[i+1]):
    i += 1
while(i<largo-1) and (lista[i]==lista[i+1]):
    i += 1
while(i<largo-1) and (lista[i]>lista[i+1]):
    i += 1

if(i == largo-1):
    print("YES")
else:
    print("NO")

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

if(n==1):
    print("YES")
if(n>=2):
    begin = 0;
    end = len(array)-1

    while(array[begin]<array[begin+1] if begin<end else False):
            begin+=1

    while(array[end]<array[end-1] and end!=begin):
        end-=1

    test = set()

    for i in range(begin,end+1):
        test.add(array[i])
    if(len(test)==1 or begin==end):
        print("YES")
    else:
        print("NO")

n=int(input())
sl=list(map(int,input().split()))
b=0
c=0
d=0
i=0
j=0
for i in range(1,n):
    if sl[i]>sl[i-1]:
        if (b==1 or c==1):
            print("NO")
            exit()
        d=1
    if sl[i]==sl[i-1]:
        if b==1:
            print("NO")
            exit()
        c=1
    if sl[i]<sl[i-1] :
        b=1
print("YES")
exit()

from collections import *
import sys

# "". join(strings)

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

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

n= ri()

aa = rl()
ans='YES'
if n>1:

    for i in range(n-1):
        if aa[i+1]<=aa[i]:
            end_up = i
            break
    else:
        end_up=n-1
        start_down=n-1

    for i in range(end_up,n-1):
        if aa[i+1]!=aa[i]:
            start_down=i
            break
    else:
        start_down=n-1

    for i in range(start_down, n-1):
        if aa[i+1]>=aa[i]:
            ans="NO"
            break
print(ans)

no ="NO"
n =int(raw_input())
arr =map(int,raw_input().split())
if n == 1:
	print "YES"
	quit()
a =0
b =0
c =0
for i in range(1,n):
	if arr[i-1] < arr[i]:
		if b == 0 and c == 0:
			a =1
		else:
			print no
			quit()
	elif arr[i-1] == arr[i]:
		if c == 0:
			b =1
		else:
			print no
			quit()
	elif arr[i-1] > arr[i]:
		c =1
if a == 1 and b == 1 and c == 1:
	print "YES"
elif a == 1 and b == 1:
	print "YES"
elif b == 1:
	print "YES"
elif b == 1 and c == 1:
	print "YES"
elif a == 1 and c ==1:
	print "YES"
elif a == 1:
	print "YES"
elif c == 1:
	print "YES"
else:
	print no

def unimodal_new(mylist) :
    if len(mylist) == 1 :
        return"YES"

    i = 0
    while (mylist[i] < mylist[i+1]) and (i < len(mylist) - 2):
        i += 1

    if i == len(mylist) - 2 :
        return "YES"

    while (mylist[i] == mylist[i+1]) and (i < len(mylist) - 2):
        i += 1

    if (i == len(mylist) - 2) and (mylist[i] == mylist[i+1]) :
        return "YES"

    for j in range(i, len(mylist) - 1) :
        if mylist[j] <= mylist[j+1] :
            return "NO"

    return "YES"

if __name__ == "__main__":
    n = int(input())
    arrlist = [int(x) for x in input().split()]
    print(unimodal_new(arrlist))

n = int(raw_input())

arr = [int(i) for i in raw_input().split()]

test = []

for i in xrange(n-1):
    if arr[i] < arr[i+1]:
        test.append(-1)
    if arr[i] == arr[i+1]:
        test.append(0)
    if arr[i] > arr[i+1]:
        test.append(1)

works = "YES"

for i in xrange(n-2):
    if test[i] > test[i+1]:
        works = "NO"

print works

n=int(input())
l=[int(i) for i in input().split()]
i=1
c=0
while i<n and l[i]>l[i-1]:
    i+=1
    c+=1
while i<n and l[i]==l[i-1]:
    i+=1
    c+=1
while i<n and l[i]<l[i-1]:
    i+=1
    c+=1
print('YES' if c==n-1 else 'NO')

n = int(raw_input())
l = map(int,raw_input().split())
last = l[0]
eq = False
dec = False
i = 1
while i < n:
    current = l[i]
    if current > last:
       if eq or dec:
           print "NO"
           break
    if current == last:
        eq = True
        if dec:
            print "NO"
            break
    if current < last:
        dec = True
    last = current
    i += 1
else:
    print "YES"

n = int(raw_input())
nums = list(map(int,raw_input().split()))
f = 0
v = 1
for i in range(n-1):
  if nums[i]>nums[i+1]:
    f = 1
  if nums[i] <= nums[i+1] and f:
    v = 0
if v:
  print "YES"
else:
  print "NO"

def unimodal(arr):
    state = 0
    for i in range(0, len(arr)-1):
        if(arr[i] < arr[i+1] and (state==0)):
            state = 0
        elif(arr[i] >= arr[i+1] and (state==0 or state==1)):
            state=1
        else:
            return "NO"
            break
    return "YES"
input()
print(unimodal([int(x) for x in input().split()]))

n = int(input())
l = list(map(int, input().split(" ")))
center = max(l)

inc = False
middle = False
dec = False
flag = False
for i in range(n-1):
    if l[i] == l[i+1] and l[i] == center:
        middle = True
        continue
    if l[i] <= l[i+1] and middle:
        print("NO")
        flag = True
        break
    if l[i+1] == center:
        middle = True
    if l[i] >= l[i+1] and not middle:
        print("NO")
        flag = True
        break
if not flag:
    print("YES")

n=int(input())
arr=list(map(int,input().split()))
s,t=0,0
for i in range(1,n) :
    if arr[i]<arr[i-1] or arr[i]==arr[i-1] :    s=1
    if arr[i]>arr[i-1] and s : t=1
if t:   print("NO")
else :  print("YES")

def unimodal(a, lst):
    i = 1
    for i in range(i, a):
        if not (lst[i - 1] < lst[i]):
            break
    else:
        return "NO"

    for i in range(i, a):
        if not (lst[i - 1] == lst[i]):
            break
    else:
        return "NO"

    for i in range(i, a):
        if not (lst[i - 1] > lst[i]):
            return "NO"
    else:
        return "NO"

if __name__ == '__main__':
    a, lst = int(input()), input().split()
    lst = [int(ch) for ch in lst]
    print(unimodal(a, lst))

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

ans = 'YES'
ls = []
for i in range(n - 1):
    if a[i] < a[i + 1]:
        ls.append('<')
    elif a[i] > a[i + 1]:
        ls.append('>')
    else:
        ls.append('=')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if ls[i] == '>' and ls[j] == '<':
            ans = 'NO'
            break

print(ans)

n = int(input())
a = list(map(int, input().split()))
i = 0
j = n - 1
flag = False
while i < n - 1 and a[i] < a[i + 1]:
     i += 1
while j > 1 and a[j - 1] > a[j]:
     j -= 1
if a[i] == a[j] and i <= j:
     for k in range(i, j + 1):
          if a[k] != a[i]:
               print('NO')
               flag = True
               break
     if not flag:
          print('YES')
else:
     print('NO')

import sys
n = int(raw_input())

arr = map(int, raw_input().split())

m = max(arr)
x1 = -1
x2 = -1
for i in range(n):
    if arr[i] == m:
        x2 = i
    else:
        if x1 == -1:
            x1 = i

for i in range(x1,x2+1):
    if arr[i] != m:
        print "NO"
        sys.exit(0)

for i in range(x1):
    if arr[i] >= arr[i+1]:
        print "NO"
        sys.exit(0)

for i in range(x2, n-1):
    if arr[i] <= arr[i+1]:
        print "NO"
        sys.exit(0)

print "YES"

n=input()
my_array=[int(k) for k in input().split(' ')]

def check_increasing(lis):
    for l in range(1, len(lis)):
        if lis[l] <= lis[l-1]:
            return False

    return True

def check_decreasing(lis):
    for  i in range(1, len(lis)):
        if lis[i]>= lis[i-1]:
            return False

    return True

def get_indices(lis):
    element=None
    final=[]
    for i in range(1,len(lis)):
        if lis[i] <= lis[i-1]:
            element=lis[i-1]
            final.append(i-1)
            break

    if len(final)>0:
        for l in range(final[0]+1, len(lis)):
            if lis[l] != element:
                final.append(l)
                break

        if len(final)==1:
            final.append(-1)

    else:
        final=[-1,-1]

    return final

def solve():
    indices=get_indices(my_array)
    i=my_array[:indices[0]]
    d=my_array[indices[1]:]

    if check_increasing(i) and check_decreasing(d):
        print('YES')
        return
    else:
        print('NO')
        return

solve()

n = int(input())
l = list(map(int,input().split()))
for i in range(n-1):
	if l[i] > l[i+1]:
		break
for j in range(n-1,0,-1):
	if l[j-1] <= l[j]:
		break
if i == j:
	print("YES")
else:
	print("NO")

import itertools as it
sign = lambda x: (x > 0) - (x < 0)
n, arr = input(), [int(x) for x in input().split()]
diff = (sign(a-b) for a, b in zip(arr, arr[1:]))
diff = (set(g) for k, g in it.groupby(diff))
diff = list(it.chain.from_iterable(diff))
if diff in [[-1, 0, 1], [-1, 1], [0]]:
	print('YES')
else:
	print('NO')

def find(A):
    s=''
    for i in range(len(A)-1):
        if A[i]<A[i+1]:
            s+='i'
        elif A[i]==A[i+1]:
            s+='c'
        else:
            s+='d'
    s.lstrip('i')
    s.rstrip('d')
    s.strip('c')
    if s=='':
        return 1
    else:
        return 0

N=input()
A=list(map(int,input().strip().split(' ')))
if find(A)==1:
    print('YES')
else:
    print('NO')

def unimodal_new(mylist) :
    if len(mylist) == 1 :
        return"YES"

    i = 0
    while (mylist[i] < mylist[i+1]) and (i < len(mylist) - 2):
        i += 1

    if i == len(mylist) - 2 :
        return "YES"

    while (mylist[i] == mylist[i+1]) and (i < len(mylist) - 2):
        i += 1

    for j in range(i, len(mylist) - 1) :
        if mylist[j] <= mylist[j+1] :
            return "NO"

    return "YES"

if __name__ == "__main__":
    n = int(input())
    arrlist = [int(x) for x in input().split()]
    print(unimodal_new(arrlist))

def unimodalArray(n,x):

    grIndex = 0
    reps = 0

    for i in range(0,n-1):
        if(x[i] < x[i+1]):
            grIndex = i+1
        else:
            break

    for i in range(grIndex,n-1):
        if(x[i] == x[i+1]):
            rgrIndex = i+1
        else:
            break

    for i in range(grIndex,n-1):
        if(x[i] <= x[i+1]):
            return "NO"

    return "YES"

nRaw = input()
n = int(nRaw)

xRaw = input()
xStr = xRaw.split()
x = list(map(int, xStr))

print(unimodalArray(n,x))

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

lasti = a[0]
dd = 0
for i in range(1,n):
	cur = a[i]
	if cur <= lasti:
		dd = 1
	elif dd:
		dd = 0
		break
	lasti = cur
if dd:
	print('YES')
else:
	print('NO')

count = input()
chisla = input().split()

def strictly_increasing(L):
    return all(x<y for x, y in zip(L, L[1:]))

def strictly_decreasing(L):
    return all(x>y for x, y in zip(L, L[1:]))

max_value = max(chisla)
max_indexes = [index for index in range(len(chisla)) if chisla[index] == max_value]
difference_is_one = True
for i in range(len(max_indexes)-1):
    if (max_indexes[i+1]-max_indexes[i])>1:
        difference_is_one = False
if difference_is_one and strictly_increasing(chisla[:max_indexes[0]+1]) and strictly_decreasing(chisla[max_indexes[-1]:]):
    print("YES")
else:
    print("NO")

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

L = 1
R = n - 2
prev = arr[0]
last = arr[n - 1]

while L < n and arr[L] > prev:
    prev = arr[L]
    L += 1
while R >= 0 and arr[R] > last:
    last = arr[R]
    R -= 1

for el in range(L, R + 1):
    if arr[el] != arr[el + 1]:
        print("NO")
        exit()

print("YES")

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

if(n==1):
    print("YES")
if(n==2):
    print("NO")
if(n>=3):
    begin = 0;
    end = len(array)-1

    while(array[begin]<array[begin+1] if begin<end else False):
            begin+=1

    while(array[end]<array[end-1] and end!=begin):
        end-=1

    test = set()

    for i in range(begin,end+1):
        test.add(array[i])
    if(len(test)==1 or begin==end):
        print("YES")
    else:
        print("NO")

import itertools
import math
from collections import defaultdict

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

def solve():
    n = int(input())
    a = input_ints()
    x = 0
    while x < n - 1:
        if a[x] < a[x + 1]:
            x += 1
        else:
            break
    y = n - 1
    while y > 0:
        if a[y - 1] > a[y]:
            y -= 1
        else:
            break
    for i in range(x, y):
        if a[i] != a[x]:
            print('NO')
            return
    print('YES')

if __name__ == '__main__':
    solve()

import sys

n = sys.stdin.readline()
while n:
    arr = [int(val) for val in sys.stdin.readline().split()]
    ans = ""
    if len(arr) == 1:
        ans = "YES"
    elif len(arr) == 3:
        if (arr[0] == arr[1] and arr[1] == arr[2]) or (arr[0] <= arr[1] and arr[1] >= arr[2]):
            ans = "YES"
    else:
        status = None
        err = False
        for i in range(len(arr) - 1):
            if status is None:
                if arr[i] < arr[i + 1]:
                    status = "i"
                if arr[i] == arr[i + 1]:
                    status = "r"
                if arr[i] > arr[i + 1]:
                    status = "d"
            else:
                if arr[i] < arr[i + 1]:
                    if status == "r" or status == "d":
                        err = True
                        break
                    else:
                        status = "i"
                if arr[i] == arr[i + 1]:
                    if status == "dec":
                        err = True
                        break
                    else:
                        status = "r"
                if arr[i] > arr[i + 1]:
                    if status == "i":
                        err = True
                        break
                    else:
                        status = "d"
        if err:
            ans = "NO"
        if not (arr[-1] <= arr[-2]):
            ans = "NO"
        else:
            ans = "YES"
    print(ans)
    n = sys.stdin.readline()

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

if(n==1):
    print("YES")
if(n==2):
    print("NO")
if(n>=3):
    begin = 0;
    end = len(array)-1
    while(array[begin]<array[begin+1]):
        begin+=1

    while(array[end]<array[end-1]):
        end-=1

    test = set()

    for i in range(begin,end+1):
        test.add(array[i])
    print(begin)
    print(end)
    if(len(test)==1 or begin==end):
        print("YES")
    else:
        print("NO")

n = int(input())
arr = list(map(int , input().split()))
ans = 0
inc = 0
i=0
while ans ==0 and i+1<len(arr):
    if arr[i]==arr[i+1]:
        const = arr[i]
        arr = arr[i+2:]
        while len(arr)>1 and arr[0]==const:
            arr.remove(const)
        arr = [const] + arr
        dec = arr.copy()
        dec.sort(reverse = True)
        ans = 1
        if arr==dec:
            x = set(arr)
            if len(x)==len(arr) or (arr[0]==arr[1]):
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
        break
    elif arr[i]>arr[i+1]:
        ans = 1
        arr = arr[i+1:]
        dec = arr.copy()
        dec.sort(reverse = True)
        if arr==dec:
            x = set(arr)
            if len(x)==len(arr):
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
        break
    i = i + 1
if ans==0:
    if len(arr)==1:
        print("YES")
    else:
        print("NO")

quantity = int(input())
alist = list(map(int, input().split()))

result = 'YES'
idx = 0
if quantity > 2:
    if alist[idx] > alist[idx + 1]:
        while idx < quantity - 1:
            idx += 1
            if alist[idx] < alist[idx + 1]:
                result = 'NO'
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1] or alist[idx] == alist[idx + 1]:
                        result = 'NO'
        print(result)

    elif alist[idx] == alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
            elif alist[idx] < alist[idx + 1]:
                result = 'NO'
                # print(result)
                break
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            # if alist[idx] > alist[idx + 1]:
            #     result = 'NO'
            #     break
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        break
                    elif alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                                result = 'NO'
                                break
                        break
                break
            elif alist[idx] < alist[idx + 1]:
                idx += 1
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 1:
                    if alist[idx] > alist[idx + 1]:
                        idx += 1
                    else:
                        result = 'NO'
                        break
        print(result)
elif quantity == 2:
    if alist[0] > alist[1]:
        print('NO')
    else:
        print('YES')
elif quantity == 1:
    print('YES')

n = int(input())
data = list(map(int, input().split(' ')))
pos1 = 0
pos2 = n - 1
for i in range(1, len(data)):
    if data[i - 1] > data[i]:
        break
    else:
        pos1 += 1
for i in range(len(data) - 2, 0, -1):
    if data[i] < data[i + 1]:
        break
    else:
        pos2 -= 1
state = True
if pos1 > pos2:
    for i in range(pos2 + 1, pos1 + 1):
        if data[i] != data[i - 1]:
            state = False
elif pos1 < pos2:
    for i in range(pos1 + 1, pos2 + 1):
        if data[i] != data[i - 1]:
            state = False
main_element = data[pos1]
for i in range(1, len(data)):
    if data[i] == data[i - 1] and data[i] != main_element:
        state = False
if pos1 == 0 and pos2 == 1:
    state = True
print('YES') if state else print('NO')

pattern1=["constant"]
pattern2=["constant","down"]
pattern3=["up","constant"]
pattern4=["up","constant","down"]
pattern5=["up","down"]
patternList=[str(pattern1),str(pattern2),str(pattern3),str(pattern4),str(pattern5)]

n=input()
array = [int(x) for x in raw_input().split(" ")]
pattern=[]

for idx in range(len(array)-1):
	currentPattern=None
	if array[idx+1]>array[idx]:
		currentPattern="up"
	if array[idx+1]<array[idx]:
		currentPattern="down"
	if array[idx+1]==array[idx]:
		currentPattern="constant"
	if idx==0 or (len(pattern)>0 and pattern[-1]!=currentPattern):
		pattern.append(currentPattern)

if len(array)==1 or (str(pattern) in patternList):
	print ("YES")
else:
	print ("NO")

n = int(input())
x = list(map(int, input().split()))
flag = 0
if len(set(x)) == 1:
    print('YES')
elif n < 3:
    print('NO')
else:
    for i in range(1, n):
        if flag == 0:
            if x[i] < x[i - 1]:
                flag = 1
            elif x[i] == x[i - 1]:
                flag = 2
        elif flag == 1:
            if x[i] >= x[i - 1]:
                print('NO')
                break
        elif flag == 2:
            if x[i] > x[i - 1]:
                print('NO')
                break
            elif x[i] < x[i - 1]:
                flag = 1
        if i == n - 1:
            print('YES')

curP = 0

input()

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

f= True
for i in range(1, len(A)):
    if A[i] > A[i-1] and (curP == 1 or curP == 2):
        f = False
        break

    elif A[i] == A[i-1] and (curP == 2):
        f = False
        break

    elif A[i] == A[i-1]:
        curP = 1

    elif A[i] > A[i-1]:
        curP = 2

if f:
    print("YES")
else:
    print("NO")

def main():
    size = int(input())
    array = [int(x) for x in input().split(' ')]
    end = len(array) - 2
    has_rise = False
    has_constant = False

    for i in range(len(array) - 1):
        a, b = array[i], array[i + 1]
        if a < b:
            if has_rise or i == end:
                return 'NO'
            continue
        if a == b:
            has_constant = True
            has_rise = True
            continue
        if a > b:
            has_rise = True
            if not has_rise or not has_constant:
                return 'NO'
            continue
        return 'NO'
    return 'YES'

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

n=int(input())
a=[int(i) for i in input().split()]
stage=0
k=True
top=a[0]
for i in range(1,len(a)):
    if(a[i]>top) :
        if( stage==2 or stage==3):
            k=False
            break
        stage=1
        top=a[i]
    elif(a[i]==top):
        if(stage==3):
            k=False
            break
    else:
        stage=3
        top=a[i]
if(k):
    print("YES")
else:
    print("NO")

n = int(input())
string = input()
numbers = list(map(int, string.split()))
results = "NO"
a, b = numbers[:-1], n
for x in range(n - 1):
    if not numbers[x] < numbers[x + 1]:
        a = numbers[x]
        b = x
        break
c = n
for x in range(b, n):
    if not numbers[x] == a:
        c = x
        d = numbers[x]
        break
results = "YES"
if c != n:
    if numbers[c] < a:
        for x in range(c, n - 1):
            print(numbers[x])
            if not numbers[x] > numbers[x + 1]:
                results = "NO"
                break
    else:
        results = "NO"
print(results)

quantity = int(input())
alist = list(map(int, input().split()))

result = 'YES'
idx = 0

if quantity == 3:
    if alist[idx] > alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                    result = "NO"
                    break
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
                    if alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                                result = "NO"
                                break
        print(result)
    elif alist[idx] == alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
            if alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

elif quantity == 2:
    print('YES')
elif quantity == 1:
    print('YES')
elif quantity > 3:
    if alist[idx] > alist[idx + 1]:
        result = 'NO'
        print(result)

    elif alist[idx] == alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
            elif alist[idx] < alist[idx + 1]:
                result = 'NO'
                # print(result)
                break
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
                while idx < quantity - 1:
                    if alist[idx] == alist[idx + 1]:
                        idx += 1
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                            elif alist[idx] < alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                        break
                break
            elif alist[idx] < alist[idx + 1]:
                idx += 1
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 1:
                    if alist[idx] > alist[idx + 1]:
                        idx += 1
                    else:
                        result = 'NO'
                        break
        print(result)

n=input()
a=map(int,raw_input().split())
top=max(a)
t=[]
count=0
flag=0
for i in range(n):
	if a[i]==top:
		t.append(i)
		count+=1
for i in range(t[0]):
	if i+1<=t[0]:
		if a[i]>a[i+1]:
			flag=1
for i in range(t[0],t[count-1]+1):
	if a[i]!=top:
		flag=1
for i in range(t[count-1]+1,n):
	if i+1<n:
		if a[i]<a[i+1]:
			flag=1
if flag==1:
	print 'NO'
else:
	print 'YES'

n=input()
my_array=[int(k) for k in input().split(' ')]

def check(lis):
    for i in range(1,len(lis)):
        if lis[i] > lis[i-1]:
            return False
    return True

def handle(lis):
    for i in range(1,len(lis)):
        if lis[i] <= lis[i-1]:
            if i==1:
                return False
            new_list=lis[i:]
            return check(new_list)
    return True

def solve():
    a=handle(my_array)

    if a:
        print("YES")
    else:
        print('NO')

solve()

from sys import stdin, stdout

n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))

label = 0

if len(set(values)) == 1:
    label = 1

for i in range(n):
    a = values[:i]

    if sorted(a) == a:
        for j in range(i + 2, n):
            b = values[i:j]

            if len(set(b)) == 1 and sorted(values[j:], reverse = True) == values[j:]:
                label = 1
                break

if label:
    stdout.write('YES')
else:
    stdout.write('NO')

def check(c):
  combs = [["i", "c", "d"], ["c"], ["c", "d"], ["i","c"],["i", "d"]]
  if removeNeighbours(list(c)) in combs: return True
  return False

def removeNeighbours(l):

  i = 0
  while i < len(l)-1:
      if l[i] == l[i+1]:
          del l[i]
      else:
          i = i + 1
  return l

def solve(a):
  c = ""

  for i in range(len(a) - 1):
    if a[i] < a[i+1]:
      c += "i"
    elif a[i] == a[i+1]:
      c += "c"
    elif a[i] > a[i+1]:
      c += "d"

  if len(a) == 1: return True
  elif check(c): return True
  return False

N = int(input())
A = [int(i) for i in input().split()]
print("YES" if solve(A) else "NO", end = "")

n = input()
arr = map(int, raw_input().split(' '))
blocks = []

if len(arr) == 1:
    print('YES')
else:

    for i in range(1, n):

        diff = arr[i] - arr[i-1]
        if diff > 0:
            block = '+'
        elif diff == 0:
            block = '='
        else:
            block = '-'

        if len(blocks) > 0:
            if blocks[-1] != block:
                blocks.append(block)
        else:
            blocks.append(block)

    status = ''.join(blocks)
    print(status)
    if status == '+=-' or status == '=' or status == '+=' or status == '=-' or status == '+-':
        print('YES')
    else:
        print('NO')

x=int(input())
a=list(map(int,input().split()))
b=[]
a.append(0)
for i in range(x):
	if a[i]<a[i+1]:
		b.append(a[i])
	else:
		break
for t in range(i,x):
	if a[t]==a[t+1]:
		b.append(a[t])
	else:
		break
for p in range(t,x):
	if a[p]>a[p+1]:
		b.append(a[p])
	else:
		break
if b==a:
	print('YES')
else:
	print('NO')
#author:SK__Shanto__㋛
#code__define__your__smartness

def find(A):
    s=''
    for i in range(len(A)-1):
        if A[i]<A[i+1]:
            s+='i'
        elif A[i]==A[i+1]:
            s+='c'
        else:
            s+='d'
    s.lstrip('i')
    s.rstrip('d')
    s.strip('c')
    if s=='':
        return 1
    else:
        return 0

N=input()
A=list(map(int,input().strip().split(' ')))
if find(A)==1:
    print('YES')
else:
    print('NO')

n = int(input())
arr = list(map(int , input().split()))
ans = 0
inc = 0
i=0
while ans ==0 and i+1<len(arr):
    if arr[i]==arr[i+1]:
        const = arr[i]
        arr = arr[i+2:]
        while len(arr)>1 and arr[0]==const:
            arr.remove(const)
        dec = arr.copy()
        dec.sort(reverse = True)
        ans = 1
        if arr==dec:
            x = set(arr)
            if len(x)==len(arr):
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
        break
    elif arr[i]>arr[i+1]:
        ans = 1
        arr = arr[i+1:]
        dec = arr.copy()
        dec.sort(reverse = True)
        if arr==dec:
            x = set(arr)
            if len(x)==len(arr):
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
        break
    i = i + 1
if ans==0:
    if len(arr)==1:
        print("YES")
    else:
        print("NO")

n = input()
arr = input()

n = int(n)

def problem8(n,arr):
    arr = arr.split()
    bajando = False
    check = False
    increasing = False
    same = False
    cont=0

    if len(arr)==1:
        print("YES")
        return

    for i in range(0,len(arr)-1):

        if arr[i]<arr[i+1]:
            increasing = True
            cont+=1
        elif arr[i]==arr[i+1]:
            same = True
            if check:
                if num!=arr[i]:
                    good=False
                    print ("NO")
                    return
                else:
                    good = True

        else:
            bajando = True

        if same:
            num = arr[i]
            check = True

        if cont<2 and increasing:
            good = False

        if bajando:
            if arr[i+1]<=arr[i]:
                good= True
            else:
                good = False

    if good:
        print("YES")
    else:
        print("NO")

problem8(n,arr)

n = int(input())
a = list(map(int,input().split()))
flag = True
f =f3 = True
for i in range(1,n):
	if flag==True:
		if a[i]==a[i-1]:
			flag = False
			prev = a[i-1]
		elif a[i]<a[i-1]:
			f3 = False
	else:
		if f3==True and a[i]==prev:
			f = True
		else:
			f3 = False
			if a[i]>=a[i-1]:
				f = False
				break
if f==True:
	print("YES")
else:
	print("NO")

import sys

nu = input()
m = [int(i) for i in input().split()]
if len(m) < 3:
    print('NO')
    sys.exit()

prev_ind = 1
prev = m[0]
ind = lambda x, y: int((y-x)/abs(y-x)) if y != x else 0

for i in m[1:]:
    #print(i)
    if ind(prev, i) <= prev_ind:
        #print(ind(prev, i))
        prev_ind = ind(prev, i)
        prev = i
    else :
        print('NO')
        sys.exit()
print('YES')

n=input()
my_array=[int(k) for k in input().split(' ')]

def check_increasing(lis):
    if len(lis)==1:
        return False

    for l in range(1, len(lis)):
        if lis[l] <= lis[l-1]:
            return False

    return True

def check_decreasing(lis):
    if len(lis)==1:
        return False

    for  i in range(1, len(lis)):
        if lis[i]>= lis[i-1]:
            return False

    return True

def get_indices(lis):
    element=None
    final=[]
    for i in range(1,len(lis)):
        if lis[i] <= lis[i-1]:
            element=lis[i-1]
            final.append(i-1)
            break

    if len(final)>0:
        for l in range(final[0]+1, len(lis)):
            if lis[l] != element:
                final.append(l-1)
                break

        if len(final)==1:
            final.append(-1)

    else:
        final=[-1,-1]

    return final

def solve():
    indices=get_indices(my_array)
    i=my_array[:indices[0]]
    d=my_array[indices[1]:]

    if check_increasing(i) and check_decreasing(d):
        print('YES')
        return
    else:
        print('NO')
        return

solve()

# -*-coding=utf-8-*-
def helper():
	n = int(raw_input())
	arr = map(int, raw_input().split())
	L = 1
	R = n-1
	while L < n and arr[L-1] < arr[L]:
		L+=1
	while R > 1 and arr[R] < arr[R-1]:
		R-=1
	# print 'L: ',L
	# print 'R: ',R
	while L - 1 <= R:
		if arr[L-1] != arr[R]:
			return False
		R-=1

	return True
if helper():
	print 'YES'
else:
	print 'NO'

def udimol(a):
    last = a[0]
    status = 0
    for x in a[1:]:
        if status == 0:
            if x == last:
                status = 1
            elif x > last:
                pass
            else:
                status = 2
            last = x
        elif status == 1:
            if x > last:
                status = 2
                last = x
            elif x == last:
                last = x
            else:
                return 'NO'
        else:
            if x < last:
                last = x
            else:
                return 'NO'

    return 'YES'

raw_input()
s = [int(x) for x in raw_input().split(' ')]
print udimol(s)

def main():
    read = lambda: tuple(map(int, input().split()))
    n = read()[0]
    l = read()
    if len(l) == 1:
        return "YES"
    lv = l[0]
    ss = []

    for v in l[1:]:
        state = "inc" if v > lv else "dec" if v < lv else "norm"
        if len(ss) == 0:
            ss += [state]
        elif ss[-1] != state:
            if ss[-1] == "inc" and state == "dec":
                ss += ["norm"]
            ss += [state]
        lv = v
    for state in ('inc', 'dec', 'norm'):
        if ss.count(state) > 1:
            return "NO"
    if len(ss) == 1:
        return "YES" if ss == ["norm"] else "NO"
    if len(ss) == 2:
        return "YES" if ss == ["norm", "dec"] or ss == ["inc", "norm"] else "NO"
    return "YES" if ss == ['inc', 'norm', 'dec'] else "NO"
print(main())

n = int(input())
data = list(map(int, input().split(' ')))
pos1 = 0
pos2 = n - 1

hash_table = {}
for item in data:
    if item not in hash_table:
        hash_table[item] = 1
    else:
        hash_table[item] += 1

has_two = False

for value in hash_table.values():
    if value > 1 and has_two == False:
        has_two = True
    elif value > 1 and has_two == True:
        print('NO')
        exit(0)

for i in range(1, len(data)):
    if data[i - 1] > data[i]:
        break
    else:
        pos1 += 1

for i in range(len(data) - 2, 0, -1):
    if data[i] < data[i + 1]:
        break
    else:
        pos2 -= 1

state = True

for i in range(pos1 + 1, pos2 + 1):
    if data[i] != data[i - 1]:
        state = False

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

n = input()
arr = input()

n = int(n)

def problem8(n,arr):
    arr = arr.split()
    cont = 0
    num=0
    increasing = False
    decreasing = False
    same = False

    good = True

    for i in range(0,len(arr)-1):
        if int(arr[i]) == int(arr[i+1]) and not same:
            num=arr[i]

        if (int(arr[i]) < int(arr[i+1])):
            if decreasing:
                print("NO")
                return

        else:
            if int(arr[i]) == int(arr[i+1]):
                same = True
                if num!= arr[i]:
                    print("NO")
                    return

            else:
                if int(arr[i])>int(arr[i+1]):
                    decreasing = True

    if good:
        print("YES")
    else:
        print("NO")

problem8(n,arr)

import sys
n = int(input())
arr = list(map(int,input().split()))
s = ''
pre = arr[0]
for i in range(1,n):
    if( pre < arr[i] ):
        if( 'i' not in s ):
            s += 'i'
    elif( pre == arr[i] ):
        if( 'c' not in s ):
            s += 'c'
    elif( pre > arr[i] ):
        if( 'd' not in s):
            s += 'd'
    pre = arr[i]
if( s == 'icd' or s == 'c' or s == 'ic' or s == 'cd'):
    print('YES')
else:
    print('NO')

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 24 20:04:04 2018

@author: brian
"""

n=int(input())
b=list(map(int,input().split(" ")))
aux=[]
s=""
if not (len(b)-1):
    print("Yes")
else:
    for i in range(1,n):
        if s=="":
            if(b[i]>b[i-1]):
                s="a"
            elif(b[i]==b[i-1]):
                s="r"
            else:
                #print("No")
                s="d"
                break
        elif s=="a":
            if(b[i] in aux):
                s="r"
            elif(b[i]<b[i-1]):
                #print("No")
                s="f"
                break
        elif s=="r":
            if(b[i]<b[i-1]):
                s="d"
            elif(b[i]==b[i-1]):
                continue
            else:
                #print("No")
                s="f"
                break
        elif s=="d":
            if(b[i]<b[i-1]):
                continue
            else:
                s="f"
                break

        if(b[i] not in aux):
            aux.append(b[i])
    print("Yes" if not(s=="f") else "No")

def get(l):
    z=l[0]
    flag=0
    for i in l[1:]:
        if i-z>0 and flag==0:
            continue
        if i-z==0 and flag<=1:
            if flag==0:
                flag+=1
        elif i-z<0 and flag in [1,2]:
            if flag==1:
                flag+=1
        else:
            return 'NO'
        z = i
    return 'YES'

_ = input()
l = list(map(int,input().split()))
print(get(l))

quantity = int(input())
alist = list(map(int, input().split()))

result = 'YES'
idx = 0

if quantity == 3:
    if alist[idx] > alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

    if alist[idx] < alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                result = "NO"
                break
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
                    if alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                                result = "NO"
                                break
        print(result)
    if alist[idx] == alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
            if alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

elif quantity == 2:
    if alist[0] > alist[1]:
        print('NO')
    else:
        print('YES')
elif quantity == 1:
    print('YES')
elif quantity > 3:
    if alist[idx] > alist[idx + 1]:
        result = 'NO'
        print(result)

    elif alist[idx] == alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
            elif alist[idx] < alist[idx + 1]:
                result = 'NO'
                # print(result)
                break
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
                while idx < quantity - 1:
                    if alist[idx] == alist[idx + 1]:
                        idx += 1
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                            elif alist[idx] < alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                        break
                break
            elif alist[idx] < alist[idx + 1]:
                idx += 1
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 1:
                    if alist[idx] > alist[idx + 1]:
                        idx += 1
                    else:
                        result = 'NO'
                        break
        print(result)

# -*- coding: utf-8 -*-
"""Untitled33.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1oqVApQHSdAnOYMkZjMFV-dBn3Cnw0983
"""

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

if n == 1:
    print('YES')
else:
    a = []
    b = []
    c = []
    for i in range(n-1):
        j = i + 1
        if arr[i] < arr[j]:
            a.append(arr[i])
        elif arr[i] == arr[j]:
            c.append(arr[j])
        elif arr[i] > arr[j]:
            b.append(arr[j])

    x1 = sorted(a)
    x2 = sorted(b, reverse = True)
    if a == x1 and b == x2 and len(c)!=0:
        print('YES')
    else:
        print('NO')

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

ans = 'YES'
ls = []
for i in range(n - 1):
    if a[i] < a[i + 1]:
        ls.append('<')
    elif a[i] > a[i + 1]:
        ls.append('>')
    else:
        ls.append('=')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if ls[i] == '>' and ls[j] == '<':
            ans = 'NO'
            break

print(ans)

def comprobar(k, n):
    temp = n[k - 1]
    t2 = n[k - 2]
    while temp < t2 and len(n) > 1:
        n.pop()
        temp = t2
        k = k - 1
        t2 = n[k - 2]
    k = len(n)
    if k > 1:
        temp = n[0]
        t2 = n[1]
        while temp < t2 and len(n) > 2:
            n.pop(0)
            temp = t2
            t2 = n[1]
        k = len(n)
        n.sort()
        if n[0] < n[k - 1] and k == 2:
            return 'YES'
        elif n[0] == n[k - 1]:
            return 'YES'
        return 'NO'
    return 'NO'

def main():
    k = input()
    n = [int(x) for x in raw_input().split()]
    if k == 1:
        print 'YES'
    else:
        print comprobar(k, n)

main()

n=int(input())
s=list(map(int,input().split()))
i=0
f=True
a=0
b=0
c=0
for i in range(n-1):
    if s[i]<s[i+1]:
        if (s[i]<s[i+1] and b==1) or (s[i]<s[i+1] and c==1):
            f=False
            break
        a=1
    else:
        if s[i]==s[i+1] or (s[i-1]<s[i] and s[i]>s[i+1]):
            b=1
        else:
            if s[i]>s[i+1]:
                if (s[i]>s[i+1] and b==0):
                    f=False
                    break
                c=1
if b==0:
    f=False
if f==True or n==1:
    print("YES")
else:
    print("NO")

import sys

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

ch = True
if( n == 1 ):
    print 'YES'
elif( a[0] > a[1] ):
    print 'NO'
else:
    i = 0
    while( a[i] < a[i + 1] ):
        i += 1
        if( i == n - 1 ):
            break
    if( i < n - 1 ):
        while( a[i] == a[i + 1] ):
            i += 1
            if( i == n - 1 ):
                break
        for j in range(i, n - 1):
            if( a[j] <= a[j + 1] ):
                print 'NO'
                ch = False
                break
        if( ch == True ):
            print 'YES'
    else:
        print 'NO'

# -*- coding: utf-8 -*-
"""Untitled33.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1oqVApQHSdAnOYMkZjMFV-dBn3Cnw0983
"""

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

if n == 1:
    print('YES')
else:
    a = []
    b = []
    c = []
    for i in range(n-1):
        j = i + 1
        if arr[i] < arr[j]:
            a.append(arr[i])
        elif arr[i] == arr[j]:
            c.append(arr[j])
        elif arr[i] > arr[j]:
            b.append(arr[j])

    x1 = sum(a)
    x2 = sum(b)
    x3 = sum(c)
    if (x1+x2+(2*(x3))) == sum(arr):
        print('YES')
    else:
        print('NO')

import sys

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

pivot = int(n/2)
inc = False
for i in range(n-1):
    if i < pivot:

        if a[i] >= a[i+1] and inc == False:
           print('NO')
           sys.exit(0)
        else:
            inc = True
    else:
        if a[i] < a[i+1]:
            print('NO')
            sys.exit(0)

print('YES')

length = input()
numbers = map(int, raw_input().split())
a = numbers[0]
uni = True
middle = False
end = False
for i in range (1,length):
        b = numbers[i]
        if  b < a and not end:
                uni = False
                break
        if b == a:
                middle = True
        if a < b and middle:
                uni = False
                break
        if a > b and middle:
                middle = False
        if a < b and end:
                uni = False
                break
print 'YES' if uni else 'NO'

import sys
t = int(input())
inc,c,d = 0,0,0
arr = list(map(int,input().split(' ')))
for i in range(1,t):
    if arr[i]>arr[i-1]:
        if d == 1 or c == 1:
            print('NO')
            sys.exit()
        inc = 1
    elif arr[i] == arr[i-1]:
        if d == 1:
            print('NO')
        c = 1
    elif arr[i]<=arr[i-1]:
        d = 1
print('YES')

n = input()
q = map(int, raw_input().split())
d = map(lambda x: 1 if x[1]>x[0] else -1 if x[1]<x[0] else 0, zip(q[:-1], q[1:]))
r = []
l = -2
for i in d:
	if i != l: r.append(i)
	l = i
if r == [1,0,-1] or r == [1,-1] or r == [1,0] or r == [0,-1] or r == [1] or r == [0] or r == [-1]:
	print 'YES'
else:
	print 'NO'

n = int(input())
a = list(map(int, input().split()))
c = -1
sim_a = []
res_a = []

for i in range(0, n):
    if i is 0:
        sim_a.append(a[i])
        continue
    if a[i] is a[i - 1]:
        if c != -1 and c != a[i]:
            print("NO")
            exit()
        c = a[i]
        continue
    sim_a.append(a[i])

for i in range(1, len(sim_a)):
    res_a.append(sim_a[i] - sim_a[i - 1])

# print(res_a)

cnt = 0
for i in range(1, len(res_a)):
    if res_a[i] * res_a[i - 1] < 0:
        cnt += 1

if cnt <= 1:
    print("YES")
else:
    print("NO")

n = int(raw_input())
l = map(int,raw_input().split())
last = l[0]
i = 1
st = 0
while i < n:
    current = l[i]
    if st == 0 and current == last:
        st = 1
    if st <= 1 and current < last:
        st = 2
    if st == 2 and current >= last:
        print "NO"
        break
    last = l[i]
    i+=1
else:
    print "YES"

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

n = input()
arr = input()

n = int(n)

def problem8(n,arr):
    i = 1
    arr = arr.split()
    size = len(arr)

    while i < size and arr[i - 1] < arr[i]:
        i += 1
    while i < size and arr[i - 1] == arr[i]:
        i += 1
    while i < size and arr[i - 1] > arr[i]:
        i += 1
    return i == size

problem8(n,arr)

n = int(raw_input())
a = map(int, raw_input().split())
for i in range(-1, n):
    for j in range(i + 1, n + 1):
        ok = True
        for k in range(1, i + 1):
            if a[k - 1] >= a[k]:
                ok = False
        for k in range(j, n - 1):
            if a[k] <= a[k + 1]:
                ok = False
        if len(set(a[i + 1:j])) > 1:
            ok = False
        if ok:
            print 'YES'
            exit(0)

n = input()
arr = input()

n = int(n)

def problem8(n,arr):
    arr = arr.split()
    cont = 0
    num=0
    increasing = False
    decreasing = False
    same = False

    good = True

    for i in range(0,len(arr)-1):
        if int(arr[i]) == int(arr[i+1]) and not same:
            num=arr[i]

        if (int(arr[i]) < int(arr[i+1])):
            if decreasing:
                print("DECREASE SALEO")
                return

        else:
            if int(arr[i]) == int(arr[i+1]):
                same = True
                if num!= arr[i]:
                    print("NO")
                    return

            else:
                if int(arr[i])>int(arr[i+1]):
                    decreasing = True

    if good:
        print("YES")
    else:
        print("NO")

problem8(n,arr)

n = int(input())
a = list(map(int,input().split()))[:n]
ch = 0
while(ch<n-1 and a[ch]<a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]==a[ch+1]):
    ch += 1
while(ch<n-1 and a[ch]>a[ch+1]):
    ch += 1
if(ch<=n):
    print("YES")
else:
    print("NO")

n = input()
arr = map(int, raw_input().split())
t = 1
temp = [0]
for i in xrange(n - 1):
    if arr[i] < arr[i + 1] and temp[-1] != 1:
        temp.append(1)
    elif arr[i] == arr[i + 1] and temp[-1] != 2:
        temp.append(2)
    elif arr[i] > arr[i + 1] and temp[-1] != 3:
        temp.append(3)

temp = temp[1:]
if temp == [1, 2, 3] or temp == [2, 3] or temp == [1, 2] or temp == [2] or temp == [1, 3]:
    print 'YES'
else:
    print 'NO'

def main():
    size = int(input())
    array = [int(x) for x in input().split(' ')]
    has_constant = False

    for i in range(len(array) - 1):
        a, b = array[i], array[i + 1]
        if a < b:
            if has_constant:
                return 'NO'
            continue
        if a == b:
            has_constant = True
            continue
        if a > b:
            if not has_constant:
                return 'NO'
            continue
        return 'NO'
    return 'YES'

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

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

def increase(l, r):
    result = True
    for i in range(l + 1, r):
        if (a[i - 1] >= a[i]):
            result = False
    return result

def stability(l, r):
    result = True
    for i in range(l + 1, r + 1):
        if (a[i - 1] != a[i]):
            result = False
    return result

def decrease(l, r):
    result = True
    for i in range(l + 1, r):
        if (a[i - 1] <= a[i]):
            result = False
    return result

for r in range(n):
    for l in range(r + 1):
        if (increase(0, l) and stability(l, r) and decrease(r, n)):
            print("YES")
            exit()
print("NO")

no ="NO"
n =int(raw_input())
arr =map(int,raw_input().split())
if n == 1:
	print "YES"
	quit()
a =0
b =0
c =0
for i in range(1,n):
	if arr[i-1] < arr[i]:
		if b == 0 and c == 0:
			a =1
		else:
			print no
			quit()
	elif arr[i-1] == arr[i]:
		if c == 0:
			b =1
		else:
			print no
			quit()
	elif arr[i-1] > arr[i]:
		if b == 1 or a == 1:
			c =1
		else:
			print no
			quit()
if a == 1 and b == 1 and c == 1:
	print "YES"
elif a == 1 and b == 1:
	print "YES"
elif b == 1:
	print "YES"
elif b == 1 and c == 1:
	print "YES"
elif a == 1 and c ==1:
	print "YES"
elif a == 1:
	print "YES"
else:
	print no

quantity = int(input())
alist = list(map(int, input().split()))

result = 'YES'
idx = 0
if quantity > 2:
    if alist[idx] > alist[idx + 1]:
        while idx < quantity - 1:
            idx += 1
            if alist[idx] < alist[idx + 1]:
                result = 'NO'
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1] or alist[idx] == alist[idx + 1]:
                        result = 'NO'
        print(result)

    elif alist[idx] == alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
            elif alist[idx] < alist[idx + 1]:
                result = 'NO'
                # print(result)
                break
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                result = 'NO'
                break
            elif alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        break
                    elif alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                                result = 'NO'
                                break
                        break
                break
            elif alist[idx] < alist[idx + 1]:
                idx += 1
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 1:
                    if alist[idx] > alist[idx + 1]:
                        idx += 1
                    else:
                        result = 'NO'
                        break
        print(result)
elif quantity == 2:
    if alist[0] > alist[1]:
        print('NO')
    else:
        print('YES')
elif quantity == 1:
    print('YES')

def unimodal():
    import sys
    nList = []
    temp = 0
    N = int(input())
    S = input()
    nList = S.split()
    nList = [int(i) for i in nList]
    for x in range(len(nList)-2):
        if (nList[x+2] - nList[x+1] <= nList[x+1] - nList[x]):
            pass
        else:
            print("NO")
            sys.exit()
    print("YES")

unimodal()

from sys import maxsize, stdout, stdin,stderr
mod = int(1e9 + 7)
import re #can use multiple splits
def tup():return map(int,stdin.readline().split())
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return input().strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
from  math import  log2,sqrt
from collections import defaultdict
# s= S().split()
# n = I()
#
# d='^>v<'
# if n%2==0:print('undefined')
# else:
#     st =d.find(s[0]).__index__()
#     en = d[(st+n)%4]
#     if en==s[1]:print('cw')
#     elif d[(st-n)%4]==s[1]:print('ccw')
#     else:print('undefined')
#
# #when k it is even it will end up in the same position so direction can't be determined
# #
# k = I()
# n =S()
# arr = sorted(list(map(int,n)))
# cnt =sum(arr)
# ans = 0
# #print(arr,cnt)
# for i in arr:
#     if  cnt < k:
#         cnt+=9 - i
#         ans+=1
# print(ans)
# #increasing sum by 9-d

n,ls = I(),lint()
d = defaultdict(int)
for i in ls:
    d[i]+=1
f =1;ans = 1;cnt =0; i =0
while i < n -1:
    if f==1:
        if ls[i] < ls[i+1]:pass
        #elif ls[i]==ls[i+1]:pass
        elif ls[i] > ls[i+1]:
            f =0
    elif f==0:
        if ls[i] > ls[i+1]:pass
        elif ls[i] <= ls[i+1]:
            ans =0
            break
    i+=1
print("YES") if ans else print("NO")

n = int(input())
string = input()
numbers = list(map(int, string.split()))
results = "NO"
b = n
for x in range(n - 1):
    if not numbers[x] < numbers[x + 1]:
        a = numbers[x]
        b = x
if b != n:
    results = "YES"
    c = n
    for x in range(b, n):
        if not numbers[x] == a:
            c = x
    if c != n:
        for x in range(c, n - 1):
            if not numbers[x] > numbers[x + 1]:
                results = "NO"
                break
print(results)

n = int(input())
a = list(map(int, input().split()))
i = 0
j = n - 1
flag = False
while i < n - 1 and a[i] < a[i + 1]:
     i += 1
while j > 1 and a[j - 1] > a[j]:
     j -= 1
if a[i] == a[j]:
     for k in range(i, j + 1):
          if a[k] != a[i]:
               print('NO')
               flag = True
               break
     if not flag:
          print('YES')
else:
     print('NO')

x=int(input())
a=list(map(int,input().split()))
print((lambda x,y: 'YES' if sorted(x)==x and sorted(y,reverse=True)==y else 'NO')([a[i] for i in range(a.index(max(a)))],[a[i] for i in range(a.index(max(a)),x)]))
#author:SK__Shanto__㋛
#code__define__your__smartness

m = [int(i) for i in input().split(' ')]

print(m)

j = m[0]
k = 0
err = False
for i in m[1:]:
    k += 1
    if i > j:
        j = i
        continue
    elif i == j:
        j = i
        break
    else:
        print('NO')
        err = True
        break

if not err:
    for i in m[k:]:
        k += 1
        if i == j:
            continue
        if i < j:
            j = i
            break
        else:
            print("NO")
            err = True
            break
        j = i

if not err:
    for i in m[k:]:
        k+=1
        if i<j:
            j = i
            continue
        else:
            print('NO')
            err = True
            break
        j = i
if not err:
    print('YES')

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

ans = 'YES'
ls = []
for i in range(n - 1):
    if a[i] < a[i + 1]:
        ls.append('<')
    elif a[i] > a[i + 1]:
        ls.append('>')
    else:
        ls.append('=')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if ls[i] == '>' and ls[j] == '<':
            ans = 'NO'
            break

print(ans)

n=input()
array = [int(x) for x in raw_input().split(" ")]
downPattern = False
constantPattern = False
uni = True
for idx in range(len(array)-1):
	if constantPattern:
		if array[idx+1]==array[idx]:
			print ("NO")
			uni=False
			break;
	if array[idx+1]<array[idx]:
		downPattern=True
	if array[idx+1]==array[idx]:
		constantPattern=True
	if downPattern:
		if array[idx+1]>array[idx]:
			print ("NO")
			uni=False
			break;
if uni:
	print ("YES")

from collections import *
import sys

# "". join(strings)

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

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

n= ri()

aa = rl()
ans='YES'
if n>1:

    for i in range(n-1):
        if aa[i+1]<=aa[i]:
            break
    end_up = i
    for i in range(end_up,n-1):
        if aa[i+1]!=aa[i]:
            start_down=i
            break
    else:
        start_down=n-1

    for i in range(start_down, n-1):
        if aa[i+1]>=aa[i]:
            ans="NO"
            break
print(ans)

n = raw_input()
array = [int(x) for x in raw_input().split()]

fase = 0
anterior = 0
res = "YES"

for num in array:
	if fase == 0:
		if num < anterior:
			fase = 1
			if num != anterior:
				fase = 2
				if num > anterior:
					res = "NO"
					break
				else:
					anterior = num
			else:
				anterior = num
		else:
			anterior = num

	elif fase == 1:
		if num != anterior:
			fase = 2
			if num > anterior:
				res = "NO"
				break
			else:
				anterior = num
		else:
			anterior = num

	else:
		if num > anterior:
			res = "NO"
			break
		else:
			anterior = num

print res

n = int(raw_input())

a = [int(x) for x in raw_input().split()]

i = 0
while i < n - 1 and a[i] < a[i + 1]:
    i += 1
if i == n - 1:
    print 'NO'
    exit()

while i < n - 1 and a[i] == a[i + 1]:
    i += 1

if i < n - 1:
    while i < n - 1 and a[i] > a[i + 1]:
        i += 1

if i < n - 1:
    print 'NO'
    exit()

print 'YES'

n=int(input())
a=[int(x) for x in input().split()]
asc=con=des=False
wasc=wcon=wdes=False
uni=True
for x in range(1,n):
	if(a[x] > a[x-1]):
		wasc=True
		if(wdes or wcon):
			uni=False
			break
		continue
	else:
		if(a[x] == a[x-1]):
			wcon=True
			if(wdes):
				uni=False
				break
			continue
		else:
			if(a[x] < a[x-1]):
				wdes=True
				if(not wcon and not wasc):
					uni=False
					break
				continue
			else:
				des=False

if(uni):print("YES")
else:print("NO")

n=int(input())
l=list(map(int, input().split()))
x=[]
if n==1: print("YES")
else:
  for i in range(n-1):
    if l[i]<l[i+1]: x.append(1)
    elif l[i]==l[i+1]: x.append(0)
    else: x.append(-1)
  if x.count(1)==x.count(-1)==0: pass
  elif x.count(1)*x.count(-1)==0: n=0
  else:
    k=1
    if x.count(0)==0: j=-1
    else: j=-2
    while k>j:
      for i in x:
        if i!=k and j==-1: k-=2
        else: k-=1
      if k<=j: n=0
  print("YES" if n!=0 else "NO")

__author__ = 'Esfandiar'
n = int(input())
a = list(map(int,input().split()))
f = 0
for i in range(1,n):
    if f == 0:
        if a[i] <= a[i-1]:
            f = 1
    else:
        if a[i] > a[i-1]:
            print('NO')
            exit()

print("YES")

length = input()
numbers = map(int, raw_input().split())
a = numbers[0]
uni = True
start = False
middle = False
end = False
for i in range (1,length):
        b = numbers[i]
        if  a > b:
                end = True
                if not end and not middle and not start:
                        uni = False
                        break
                elif middle:
                        middle = False
                        end = True
                start = False
        elif b == a:
                start = False
                middle = True
        elif a < b:
                start = True
                if middle:
                        uni = False
                        break
                elif end:
                        uni = False
                        break
        a = b
print 'YES' if uni else 'NO'

quantity = int(input())
alist = list(map(int, input().split()))

result = 'YES'
idx = 0

if quantity == 3:
    if alist[idx] > alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                result = "NO"
                break
            if alist[idx] == alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
                    if alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                                result = "NO"
                                break
        print(result)
    elif alist[idx] == alist[idx + 1]:
        while idx < quantity - 2:
            idx += 1
            if alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1] or alist[idx] < alist[idx + 1]:
                        result = "NO"
                        break
            if alist[idx] < alist[idx + 1]:
                result = "NO"
                break
        print(result)

elif quantity == 2:
    if alist[0] > alist[1]:
        print('NO')
    else:
        print('YES')
elif quantity == 1:
    print('YES')
elif quantity > 3:
    if alist[idx] > alist[idx + 1]:
        result = 'NO'
        print(result)

    elif alist[idx] == alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
            elif alist[idx] < alist[idx + 1]:
                result = 'NO'
                # print(result)
                break
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 2:
                    idx += 1
                    if alist[idx] == alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                break
        print(result)

    elif alist[idx] < alist[idx + 1]:
        idx += 1
        while idx < quantity - 1:
            if alist[idx] == alist[idx + 1]:
                idx += 1
                while idx < quantity - 1:
                    if alist[idx] == alist[idx + 1]:
                        idx += 1
                    elif alist[idx] < alist[idx + 1]:
                        result = 'NO'
                        # print(result)
                        break
                    elif alist[idx] > alist[idx + 1]:
                        while idx < quantity - 2:
                            idx += 1
                            if alist[idx] == alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                            elif alist[idx] < alist[idx + 1]:
                                result = 'NO'
                                # print(result)
                                break
                        break
                break
            elif alist[idx] < alist[idx + 1]:
                idx += 1
            elif alist[idx] > alist[idx + 1]:
                while idx < quantity - 1:
                    if alist[idx] > alist[idx + 1]:
                        idx += 1
                    else:
                        result = 'NO'
                        break
        print(result)

R= lambda: map(int,input().split())
n=int(input())
l=list(R())
if n==1:
    print("YES")
else:
    for i in range(1,n):
        if(l[i]<l[i-1]):    break
    r=l[i:]
    r.sort(reverse=True)
    r=l[:i]+r
    for i in range(n):
        if(l[i]!=r[i]):
            print("NO")
            exit()
    print("YES")

x=int(input())
y=input().split()
if x==1 or x==2:
  print("YES")
max=-1
maxpos=-1
funi=False
Luni=False
for i in range(x):
  if int(y[i])>max:
    max=int(y[i])
    maxpos=i
for i in range(0,maxpos):
  funi=False
  if int(y[i])<=int(y[i+1]):
    funi=True
for i in range(maxpos,x-1):
  Luni=False
  if int(y[i])>=int(y[i+1]):
    Luni=True
if maxpos==0 and int(y[0])==int(y[x-1]):
  print("YES")
elif maxpos==0 and Luni:
  print("YES")
elif maxpos==x-1 and funi:
  print("YES")

elif funi and Luni :
  print("YES")
else:
  print("NO")

def unimodal(arr):
    state = 0
    for i in range(0, len(arr)-1):
        if(arr[i] < arr[i+1] and (state==0 or state==1)):
            state = 1
        elif(arr[i] >= arr[i+1] and (state==1 or state==2) ):
            state=2
        else:
            return "NO"
            break
    return "YES"
input()
print(unimodal(input().split()))