There are $n$ pillars aligned in a row and numbered from $1$ to $n$.

Initially each pillar contains exactly one disk. The $i$-th pillar contains a disk having radius $a_i$.

You can move these disks from one pillar to another. You can take a disk from pillar $i$ and place it on top of pillar $j$ if all these conditions are met:

  there is no other pillar between pillars $i$ and $j$. Formally, it means that $|i - j| = 1$;  pillar $i$ contains exactly one disk;  either pillar $j$ contains no disks, or the topmost disk on pillar $j$ has radius strictly greater than the radius of the disk you move. 

When you place a disk on a pillar that already has some disks on it, you put the new disk on top of previously placed disks, so the new disk will be used to check the third condition if you try to place another disk on the same pillar.

You may take any disk and place it on other pillar any number of times, provided that every time you do it, all three aforementioned conditions are met. Now you wonder, is it possible to place all $n$ disks on the same pillar simultaneously?


-----Input-----

The first line contains one integer $n$ ($3 \le n \le 2 \cdot 10^5$) — the number of pillars.

The second line contains $n$ integers $a_1$, $a_2$, ..., $a_i$ ($1 \le a_i \le n$), where $a_i$ is the radius of the disk initially placed on the $i$-th pillar. All numbers $a_i$ are distinct.


-----Output-----

Print YES if it is possible to place all the disks on the same pillar simultaneously, and NO otherwise. You may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).


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

Output
YES

Input
3
3 1 2

Output
NO



-----Note-----

In the first case it is possible to place all disks on pillar $3$ using the following sequence of actions:

  take the disk with radius $3$ from pillar $2$ and place it on top of pillar $3$;  take the disk with radius $1$ from pillar $1$ and place it on top of pillar $2$;  take the disk with radius $2$ from pillar $4$ and place it on top of pillar $3$;  take the disk with radius $1$ from pillar $2$ and place it on top of pillar $3$.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Greedy algorithms


Solutions:
n = int(input())
arr = list(map(int, input().split()))
m = arr.index(max(arr))
a = sorted(arr[:m])
b = sorted(arr[m + 1:])
f = 0
if arr[:m] == a:
	f += 1
elif a == []:
	f += 1
if arr[m + 1:] == b[::-1]:
	f += 1
elif b == []:
	f += 1
print('YES' if f == 2 else 'NO')


n = int(input())
ls = [int(i) for i in input().split()]
inc = True
last = -1
dt = {}
for i in ls:
	if last < i and inc:
		None
	elif last > i:
		inc = False
	else:
		last = -5
		break
	if i in dt:
		last = -5
		break
	dt[i] = 1
	last = i
if last == -5:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
j = max(l)
p = l.index(j)
p1 = p - 1
p2 = p + 1
flag = 0
for x in range(p1, 0, -1):
	q = l[x]
	w = l[x - 1]
	if q > w:
		pass
	else:
		flag = 1
		break
for x in range(p2, n - 1):
	q = l[x]
	w = l[x + 1]
	if q > w:
		pass
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
a = [int(item) for item in input().split()]
climbing = True
prev = a[0]
for item in a[1:]:
	if climbing and prev < item:
		pass
	elif climbing and prev > item:
		climbing = False
	elif not climbing and prev > item:
		pass
	elif not climbing and prev < item:
		print('NO')
		exit()
	prev = item
print('YES')


n = int(input())
a = [int(x) for x in input().split()]
c = max(a)
b = a.index(c)
ans = 'YES'
for i in range(n - 1):
	if a[i] == c:
		pass
	elif i < b:
		if a[i] >= a[i + 1]:
			ans = 'NO'
	elif i > b:
		if a[i] <= a[i + 1]:
			ans = 'NO'
	if ans == 'NO':
		break
print(ans)


n = int(input())
A = list(map(int, input().split()))
mx = 0
for elem in A:
	if elem > mx:
		mx = elem
A.append(0)
A.reverse()
A.append(0)
A.reverse()
i_mx = A.index(mx)
B = [A[i_mx]]
l = 1
r = 1
for i in range(n - 1):
	if A[i_mx - l] > A[i_mx + r]:
		B.append(A[i_mx - l])
		l += 1
	else:
		B.append(A[i_mx + r])
		r += 1
B.reverse()
if B == sorted(B):
	print('YES')
else:
	print('NO')


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


n = int(input())
a = list(map(int, input().split()))
idx = a.index(max(a))
for i in range(idx, 0, -1):
	if a[i] < a[i - 1]:
		print('NO')
		return
for i in range(idx, n - 1):
	if a[i] < a[i + 1]:
		print('NO')
		return
print('YES')


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

def solve():
	max_ind = 0
	for i in range(1, n):
		if pillars[i] > pillars[max_ind]:
			max_ind = i
	for i in range(1, max_ind):
		if pillars[i - 1] >= pillars[i]:
			return False
	for i in range(max_ind + 2, n):
		if pillars[i - 1] <= pillars[i]:
			return False
	return True
if solve():
	print('YES')
else:
	print('NO')


import sys
import math
import bisect
import itertools
import random

def main():
	n = int(input())
	A = list(map(int, input().split()))
	p = -1
	for i in range(n):
		if A[i] == n:
			p = i
			break
	if A[0:p + 1] == sorted(A[0:p + 1]) and A[p + 1:] == sorted(A[p + 1:], reverse=True):
		print('YES')
	else:
		print('NO')
main()


n = int(input())
a = list(map(int, input().split()))
x = a.index(max(a))
l = a[:x]
r = a[x:]
ans = 'YES'
if len(l) >= 2:
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < 0:
			ans = 'NO'
			break
if len(r) >= 2:
	for i in range(len(r) - 1):
		if r[i + 1] - r[i] > 0:
			ans = 'NO'
			break
print(ans)


n = int(input())
A = [int(x) for x in input().split()]
B = sorted(A)
for i in range(1, n + 1):
	if B[i - 1] == i:
		pass
	else:
		print('NO')
		exit()
B.sort(reverse=True)
i = 1
Index = A.index(B[0])
l = Index - 1
r = Index + 1
while i < n:
	flag = 0
	if l >= 0 and A[l] == B[i]:
		l -= 1
		flag = 1
		i += 1
	elif r < n and A[r] == B[i]:
		r += 1
		flag = 1
		i += 1
	else:
		print('NO')
		exit()
if i == n:
	print('YES')
else:
	print('NO')


N = int(input())
disks = [int(x) for x in input().split()]
inc = True
result = 'YES'
for i in range(1, N):
	if disks[i] > disks[i - 1]:
		if not inc:
			result = 'NO'
			break
	elif inc:
		inc = False
print(result)


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	x = 0
	while x != n - 1 and a[x] < a[x + 1]:
		x = x + 1
	while x != n - 1 and a[x] > a[x + 1]:
		x = x + 1
	print('YES' if x == n - 1 else 'NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
up = True
for i in range(n - 1):
	if a[i] < a[i + 1] and (not up):
		print('NO')
		exit()
	elif a[i] > a[i + 1] and up:
		up = False
print('YES')


import sys
import math
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
m = max(a)
t = 0
f = 0
for i in range(len(a) - 1):
	if a[i] == m:
		t = 1
	if t == 0 and a[i] >= a[i + 1]:
		f = 1
		break
	if t == 1 and a[i] <= a[i + 1]:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
s = sorted(a)
q = a.index(max(a))
(q1, q) = (min(len(a) - 1, q + 1), max(0, q - 1))
for q2 in range(len(a) - 2, -1, -1):
	if a[q] == s[q2]:
		q = max(0, q - 1)
	elif a[q1] == s[q2]:
		q1 = min(len(a) - 1, q1 + 1)
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
maxi = max(a)
index = a.index(maxi)
flag = True
j = index
while j > 0:
	if a[j] > a[j - 1]:
		j -= 1
	else:
		flag = False
		break
j = index
while j < n - 1:
	if a[j] > a[j + 1]:
		j += 1
	else:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


def decreasing(arr, index):
	for i in range(index, 0, -1):
		if arr[i - 1] > arr[i]:
			return False
	for i in range(index, len(arr) - 1):
		if arr[i + 1] > arr[i]:
			return False
	return True

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	index = arr.index(max(arr))
	if decreasing(arr, index):
		print('YES')
		return
	print('NO')
main()


num = int(input())
disks = list(map(lambda num: int(num), input().split()))
maximum = max(disks)
for (index, num) in enumerate(disks):
	if num == maximum:
		maxindex = index
		break
flag = 0
for i in range(len(disks[:maxindex])):
	if disks[i] > disks[i + 1]:
		flag = 1
		print('NO')
		break
if flag == 0:
	for i in range(len(disks[maxindex:]) - 1):
		if disks[maxindex + i] < disks[maxindex + i + 1]:
			flag = 1
			print('NO')
			break
	if flag == 0:
		print('YES')


def main():
	import sys
	input = sys.stdin.readline
	n = int(input())
	arr = list(map(int, input().split()))
	idx = arr.index(n)
	ok = 1
	for i in range(1, idx):
		if arr[i] < arr[i - 1]:
			ok = 0
	for i in reversed(range(idx, n - 1)):
		if arr[i] < arr[i + 1]:
			ok = 0
	if ok:
		print('YES')
	else:
		print('NO')
	return 0
main()


n = input()
n = int(n)
seq = input()
seq = seq.split(' ')
seq = [int(s) for s in seq]
asc = True
maxi = seq[0]
for i in seq:
	if asc:
		if i < maxi:
			asc = False
			maxi = i
		else:
			maxi = i
	elif i > maxi:
		print('No')
		break
	else:
		maxi = i
	if i == seq[-1]:
		print('yes')


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
index = a.index(n)
flag = 1
for i in range(1, index):
	if a[i] < a[i - 1]:
		flag = 0
for i in reversed(range(index, n - 1)):
	if a[i] < a[i + 1]:
		flag = 0
if flag:
	print('YES')
else:
	print('NO')


import math
n = int(input())
l = list(map(int, input().split()))
a = -1
for i in range(n):
	if l[i] == n:
		a = i
c = -1
for i in range(1, a):
	if l[i] < l[i - 1]:
		c = 1
		break
if c == -1:
	for i in range(a, n - 1):
		if l[i] < l[i + 1]:
			c = 1
if c == -1:
	print('YES')
elif c == 1:
	print('NO')


f = int(input())
a = list(map(int, input().strip().split()))
b = max(a)
c = a.index(b)
if sorted(a[:c]) == a[:c] and sorted(a[c + 1:], reverse=True) == a[c + 1:]:
	print('YES')
else:
	print('NO')


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


n = int(input())
a = list(map(int, input().split()))
flag = 0
ans = 1
for i in range(n):
	if a[i] == n:
		flag = 1
	elif flag == 0 and a[i] > a[i + 1]:
		ans = 0
		break
	elif flag == 1 and a[i] > a[i - 1]:
		ans = 0
		break
if ans:
	print('YES')
else:
	print('NO')


def f(A):
	max_index = 0
	for i in range(1, len(A)):
		if A[i] > A[max_index]:
			max_index = i
	(i, j) = (max_index - 1, max_index + 1)
	cur = A[max_index]
	while i >= 0 or j < len(A):
		left = A[i] if i >= 0 else cur
		right = A[j] if j < len(A) else cur
		assert not (left == cur and right == cur)
		if left > cur or right > cur:
			return False
		if i < 0 or (j < len(A) and left < right):
			cur = right
			j += 1
		elif j >= len(A) or (i >= 0 and right < left):
			cur = left
			i -= 1
		else:
			assert False
	return True
n = int(input())
A = list(map(int, input().split()))
print('YES' if f(A) else 'NO')


n = int(input())
a = list(map(int, input().split()))
k = max(a)
tof = True
p = -10000000000000000000000
for i in range(n):
	if a[i] == k:
		tof = False
		p = a[i]
		continue
	if tof and a[i] < p:
		print('NO')
		exit()
	if not tof and a[i] > p:
		print('NO')
		exit()
	p = a[i]
print('YES')


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
i = a.index(max(a))
l = a[:i]
r = a[i:]
if sorted(l) == l and sorted(r, reverse=True) == r:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
ind = max(range(n), key=lambda x: a[x])
fail = False
mn = a[ind]
for i in range(ind, n):
	if a[i] > mn:
		fail = True
		break
	mn = min(mn, a[i])
if not fail:
	mn = a[ind]
	for i in range(ind, -1, -1):
		if a[i] > mn:
			fail = True
			break
		mn = min(mn, a[i])
if fail:
	print('NO')
else:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
ind = arr.index(max(arr))
for i in range(ind, n - 1):
	if arr[i + 1] >= arr[i]:
		print('No')
		exit()
for i in range(ind, 0, -1):
	if arr[i - 1] >= arr[i]:
		print('No')
		exit()
print('Yes')


from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = [[a[0], 0]]
for i in range(1, n):
	if a[i] >= m[-1][0]:
		m.append([a[i], i])
if len(m) < 2 or m[-1][0] != m[-2][0]:
	for i in range(1, m[-1][1] + 1):
		if a[i] <= a[i - 1]:
			break
	else:
		for i in range(m[-1][1] + 1, n - 1):
			if a[i] <= a[i + 1]:
				break
		else:
			print('YES')
			quit(0)
print('NO')


t = int(input())
s = input().split()
s = list(map(int, s))
mx = s.index(max(s))
flag = True
for i in range(mx):
	flag &= s[i] < s[i + 1]
for i in range(mx, t - 1):
	flag &= s[i] > s[i + 1]
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
x = list(map(int, input().rstrip().split()))
for i in range(1, n - 1):
	if x[i] < x[i - 1] and x[i] < x[i + 1]:
		print('NO')
		break
else:
	print('YES')


n = int(input())
lst = list(map(int, input().split()))[:n]
flag = 0
x = lst.index(max(lst))
if all((lst[i] < lst[i + 1] for i in range(x - 1))) and all((lst[j] > lst[j + 1] for j in range(x, len(lst) - 1))):
	flag = 1
print('YES' if flag == 1 else 'NO')


n = int(input())
a = input().split()
b = 0
c = n - 1
run = 1
while c > b:
	if int(a[b]) <= int(a[c]):
		if int(a[b]) >= int(a[b + 1]):
			print('NO')
			run = 0
			break
		else:
			b += 1
	elif int(a[c]) >= int(a[c - 1]):
		print('NO')
		run = 0
		break
	else:
		c -= 1
if run == 1:
	print('YES')


from sys import stdin
input = stdin.readline
n = int(input())
l = list(map(int, input().split(' ')))
mini = 0
for i in range(1, n - 1):
	if l[i] < l[i - 1] and l[i] < l[i + 1]:
		mini += 1
if mini:
	print('NO')
else:
	print('YES')


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


n = int(input())
a = list(map(int, input().split()))
x = a.index(n)
print('YES' if sorted(a[:x]) == a[:x] and sorted(a[x + 1:], reverse=True) == a[x + 1:] else 'NO')


n = int(input())
s = [int(i) for i in input().split()]
k = s.index(max(s))
if s[:k] == sorted(s[:k]) and s[k:] == sorted(s[k:], reverse=True):
	print('YES')
else:
	print('NO')


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
from random import randint as rn

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def min():
	return map(int, input().split())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	n = inin()
	a = ain()
	j = max(a)
	i = a.index(j)
	p = a[i]
	ans = 'YES'
	j = k = i
	j = j + 1
	k = k - 1
	while 1:
		if j < n:
			if k > -1:
				if a[j] < a[k]:
					if a[k] > p:
						ans = 'NO'
						break
					p = a[k]
					k -= 1
				else:
					if a[j] > p:
						ans = 'NO'
						break
					p = a[j]
					j += 1
			else:
				if a[j] > p:
					ans = 'NO'
					break
				p = a[j]
				j += 1
		elif k > -1:
			if a[k] > p:
				ans = 'NO'
				break
			p = a[k]
			k -= 1
		else:
			break
	print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
max_ = a.index(max(a))
flag = 0
for i in range(max_):
	if a[i] < a[i + 1]:
		flag += 1
for i in range(max_, n - 1):
	if a[i] > a[i + 1]:
		flag += 1
print('YES' if flag == n - 1 else 'NO')


n = int(input())
l = list(map(int, input().split(' ')))
id = l.index(max(l))
ans = 1
for i in range(0, id):
	ans = ans & (l[i] < l[i + 1])
for i in range(id, n - 1):
	ans = ans & (l[i] > l[i + 1])
if ans:
	print('YES')
else:
	print('NO')


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


from sys import stdin, stdout
import collections
N = int(input())
arr = [int(x) for x in stdin.readline().split()]
lr = [0, 0]
for i in range(N):
	if arr[i] == N:
		lr = [i, i]
		break
idx = {}
for i in range(N):
	idx[arr[i]] = i
for i in range(N - 1, 0, -1):
	if idx[i] == lr[0] - 1:
		lr[0] -= 1
	elif idx[i] == lr[1] + 1:
		lr[1] += 1
	else:
		print('NO')
		quit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
idx = list(range(n))
idx.sort(key=lambda i: a[i], reverse=True)
imin = imax = idx[0]
for i in idx[1:]:
	if i == imin - 1 or i == imax + 1:
		imin = min(imin, i)
		imax = max(imax, i)
	else:
		print('NO')
		exit(0)
print('YES')


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


n = int(input())
a = list(map(int, input().split(' ')))
x = a.index(max(a))
res = True
res_2 = True
for i in range(x):
	res = a[i] <= a[i + 1]
	if res == False:
		break
for i in range(x, n - 1):
	res_2 = a[i] >= a[i + 1]
	if res_2 == False:
		break
if res == True and res_2 == True:
	print('yes')
else:
	print('no')


n = int(input())
l = [int(i) for i in input().split()]
ind = l.index(max(l))
l1 = l[:ind]
l2 = l[ind:]
l2.reverse()
if sorted(l1) != l1:
	print('NO')
elif sorted(l2) != l2:
	print('NO')
else:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
ileft = iright = imax = 0
ma = arr[0]
flag = 0
for i in range(1, n):
	if arr[i] > ma:
		ma = arr[i]
		imax = i
ileft = imax - 1
iright = imax + 1
while ileft >= 0 or iright < n:
	l = r = -1
	if ileft >= 0:
		l = arr[ileft]
	if iright < n:
		r = arr[iright]
	mlr = -1
	mlr = max(l, r)
	if mlr != -1:
		if mlr >= arr[imax]:
			print('NO')
			flag = 1
			break
		else:
			arr[imax] = mlr
			if ileft >= 0 and iright < n:
				if arr[ileft] >= arr[iright]:
					ileft -= 1
				else:
					iright += 1
			elif ileft >= 0:
				ileft -= 1
			elif iright < n:
				iright += 1
if flag == 0:
	print('YES')


n = int(input())
t = list(map(int, input().split()))
for j in range(n):
	if t[j] == n:
		if sorted(t[0:j]) == t[0:j] and sorted(t[j + 1:][::-1]) == t[j + 1:][::-1]:
			print('YES')
		else:
			print('NO')


n = int(input())
line = input()
lst = []
for (idx, num) in enumerate(line.split(' ')):
	lst.append((int(num), idx))
lst.sort(reverse=True)
(left, right) = (lst[0][1], lst[0][1])
ans = 'YES'
for i in range(1, n):
	if not left - 1 <= lst[i][1] <= right + 1:
		ans = 'NO'
		break
	left = min(left, lst[i][1])
	right = max(right, lst[i][1])
print(ans)


n = int(input())
pillars = list(map(int, input().split()))
max_radius = max(pillars)
idx = pillars.index(max_radius)

def is_movable():
	for i in range(min(idx, len(pillars) - 1)):
		if not pillars[i] < pillars[i + 1]:
			return 'no'
	for i in range(idx, len(pillars) - 1):
		if not pillars[i] > pillars[i + 1]:
			return 'no'
	return 'yes'
print(is_movable())


n = int(input())
a = [int(i) for i in input().split()]
b = a
count = 0
b = True
for i in range(a.index(max(a))):
	if a[i + 1] > a[i]:
		b = True and b
	else:
		b = False and b
for i in range(a.index(max(a)), len(a) - 1):
	if a[i + 1] < a[i]:
		b = True and b
	else:
		b = False and b
if b:
	print('yes')
else:
	print('no')


n = int(input())
a = [int(_) for _ in input().split(' ')]
i = 0
for j in range(n):
	if a[j] > a[i]:
		i = j
a1 = a[:i + 1]
a2 = a[i + 1:]
flag = 1
for j in range(1, i + 1):
	if a1[j] < a1[j - 1]:
		flag = 0
		break
for j in range(1, len(a2)):
	if a2[j] > a2[j - 1]:
		flag = 0
		break
if flag == 1:
	print('yes')
else:
	print('no')


k = int(input())
m = 0
s = list(map(int, input().split()))
for i in range(k):
	if s[i] > s[m]:
		m = i
ans = 'YES'
for i in range(m - 1):
	if s[i] > s[i + 1]:
		ans = 'NO'
for i in range(m, k - 1):
	if s[i] < s[i + 1]:
		ans = 'NO'
print(ans)


n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
bol = True
num = 0
for i in range(n):
	if arr[i] == m:
		num = i
for i in range(num, n - 1):
	if arr[i] < arr[i + 1]:
		bol = False
		break
for i in range(1, num):
	if arr[i - 1] > arr[i]:
		bol = False
		break
if bol:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
x = 1
mx = max(a)
for i in range(n):
	if a[i] == mx:
		indx = i
		break
for i in range(n - 1):
	if i < indx and a[i] >= a[i + 1] or (i > indx and a[i] <= a[i + 1]):
		x = 0
		break
if x:
	print('YES')
else:
	print('NO')


a = int(input())
b = list(map(int, input().split()))
d = set(b)
if len(d) != a:
	print('NO')
	return
ima = 0
for i in range(a):
	if b[ima] < b[i]:
		ima = i
for i in range(1, ima):
	if b[i] < b[i - 1]:
		print('NO')
		return
for i in range(ima, a - 1):
	if b[i] < b[i + 1]:
		print('NO')
		return
print('YES')


n = int(input())
a = list(map(int, input().split()))
if n == 3:
	if a[0] < a[1] < a[2] or a[0] > a[1] > a[2]:
		print('YES')
	else:
		print('NO')
elif n > 3:
	l = a.index(max(a))
	if l == 0 and all((a[item] > a[item + 1] for item in range(n - 1))) or (l == -1 and all((a[item] < a[item + 1] for item in range(n - 1)))):
		print('YES')
	elif all((a[item] < a[item + 1] for item in range(l))) and all((a[item] > a[item + 1] for item in range(l + 1, n - 1))) or (all((a[item] > a[item + 1] for item in range(l))) and all((a[item] < a[item + 1] for item in range(l + 1, n - 1)))):
		print('YES')
	else:
		print('NO')


n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = l.index(a)
x = 0
y = 0
for i in range(b):
	if l[i] >= l[i + 1]:
		x = 1
		break
for i in range(b, n - 1):
	if l[i] <= l[i + 1]:
		y = 1
		break
if x == 1 or y == 1:
	print('No')
else:
	print('Yes')


from __future__ import division, print_function
mod1 = int(1000000000.0 + 7)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = inin()
	a = ain()
	temp = 0
	flag = 0
	maxx = 0
	for i in range(n):
		if maxx < a[i]:
			maxx = a[i]
			b = i
	for i in range(b - 1):
		if a[i + 1] < a[i]:
			flag = 1
			break
	if flag == 0:
		for i in range(b + 1, n - 1):
			if a[i] < a[i + 1]:
				flag = 1
				break
	if flag == 1:
		print('No')
	else:
		print('Yes')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


x = int(input())
y = list(map(int, input().split()))
t = y.index(max(y))
n = 0
q = t + 1
bool = True
while n + 1 < t:
	if y[n] < y[n + 1]:
		n += 1
	else:
		bool = False
		break
if bool == False:
	print('NO')
else:
	while q + 1 < x:
		if y[q] > y[q + 1]:
			q += 1
		else:
			bool = False
			break
	if bool == False:
		print('NO')
	else:
		print('YES')


a = int(input())
b = input()
b = list(map(lambda x: int(x), b.split(' ')))
greatest = max(b)
igreatest = b.index(greatest)
left = greatest
con = True
for i in range(igreatest - 1, -1, -1):
	if b[i] >= left:
		con = False
		break
	left = b[i]
if con == False:
	print('no')
	exit()
else:
	right = greatest
	for j in range(igreatest + 1, len(b)):
		if b[j] >= right:
			con = False
			break
		right = b[j]
if con == False:
	print('no')
else:
	print('yes')


class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def main():
	n = Read.int()
	a = Read.list_int()
	max_a = max(a)
	index = a.index(max_a)
	l_index = index - 1
	r_index = index + 1
	while True:
		if l_index >= 0 and r_index < n:
			if a[l_index] > a[r_index]:
				if a[l_index] >= max_a:
					print('NO')
					return
				max_a = a[l_index]
				l_index -= 1
			else:
				if a[r_index] >= max_a:
					print('NO')
					return
				max_a = a[r_index]
				r_index += 1
		elif l_index >= 0:
			if a[l_index] >= max_a:
				print('NO')
				return
			max_a = a[l_index]
			l_index -= 1
		elif r_index < n:
			if a[r_index] >= max_a:
				print('NO')
				return
			max_a = a[r_index]
			r_index += 1
		else:
			break
	print('YES')
t = 1
for j in range(t):
	main()


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


n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == n:
	idx = a.index(max(a))
	test = 0
	for i in range(0, idx):
		if i == 0:
			continue
		elif a[i] < a[i - 1]:
			test = 1
			break
	for i in range(idx + 1, n):
		if i == idx + 1:
			continue
		elif a[i] > a[i - 1]:
			test = 1
			break
	if test:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


t = int(input())
g = list(map(int, input().split()))
k = max(g)
flag = True
i = 0
while g[i] != k:
	if i != 0 and g[i] < g[i - 1]:
		print('NO')
		return
	i += 1
i += 1
while i < t and g[i] != k:
	if i != 0 and g[i] > g[i - 1]:
		print('NO')
		return
	i += 1
print('YES')


def solve(b):
	m = len(b)
	d = False
	for i in range(1, m):
		if a[i] < a[i - 1]:
			d = True
		elif a[i] > a[i - 1] and d:
			return False
	return True
n = int(input())
a = [int(x) for x in input().split(' ')]
if solve(a):
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
l = arr[0]
li = 0
for i in range(n):
	if arr[i] > l:
		li = i
		l = arr[i]
arl = arr[0:li + 1]
arr = arr[li:]
a = sorted(arl)
b = sorted(arr, reverse=True)
if arl != a:
	print('NO')
elif arr != b:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
idex = a.index(mx)
i = idex - 1
j = idex + 1
while i > -1 or j < n:
	if i > -1 and j < n:
		if a[i] > a[j] and a[i] < a[idex]:
			idex = i
			i -= 1
		elif a[i] < a[j] and a[j] < a[idex]:
			idex = j
			j += 1
		elif a[i] == a[j] and a[j] < a[idex]:
			idex = j
			j += 1
		else:
			print('NO')
			exit()
	elif i > -1:
		if a[i] < a[idex]:
			idex = i
			i -= 1
		else:
			print('NO')
			exit()
	elif j < n:
		if a[j] < a[idex]:
			idex = j
			j += 1
		else:
			print('NO')
			exit()
print('YES')


n = int(input())
a = [*map(int, input().split())]
i = a.index(n)
a1 = a[:i]
a1.sort()
a2 = a[i + 1:]
a2.sort(reverse=True)
if a == a1 + [n] + a2:
	print('YES')
else:
	print('NO')


n = int(input())
inputs = input().split(' ')
arr = []
for x in inputs:
	arr.append(int(x))

def largest(arr, n):
	max = arr[0]
	maxindex = 0
	for i in range(1, n):
		if arr[i] > max:
			max = arr[i]
			maxindex = i
	return maxindex
index = largest(arr, n)
arr2 = arr[index + 1:]
arr1 = arr[:index]
flag1 = 0
flag2 = 0
if all((arr1[i] <= arr1[i + 1] for i in range(len(arr1) - 1))):
	flag1 = 1
if all((arr2[i] >= arr2[i + 1] for i in range(len(arr2) - 1))):
	flag2 = 1
if flag1 == 1 and flag2 == 1:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
maxa = max(arr)
maxi = arr.index(maxa)
flag = 0
for i in range(maxi):
	if arr[i] >= arr[i + 1]:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	flag = 0
	for i in range(maxi + 1, n):
		if arr[i] >= arr[i - 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
a = list(map(int, input().split()))
if len(set(a)) != len(a):
	print('no')
	exit()
prev = 0
i = 1
while i < n and a[i] > a[prev]:
	prev = i
	i += 1
for i in range(prev + 1, n):
	if a[i] > a[i - 1]:
		print('no')
		exit()
print('yes')


from collections import defaultdict as dt
n = int(input())
a = list(map(int, input().split()))
x = 0
d = dt(lambda : 0)
for i in a:
	d[i] = d[i] + 1
	if d[i] > 1:
		print('NO')
		x = 1
		break
if x == 0:
	d = sorted(a)
	e = d[::-1]
	b = max(a)
	c = a.index(b)
	if c == 0:
		if e == a:
			print('YES')
		else:
			print('NO')
	elif c == n - 1:
		if d == a:
			print('YES')
		else:
			print('NO')
	else:
		d = sorted(a[:c + 1])
		e = sorted(a[c:])[::-1]
		if d == a[:c + 1] and e == a[c:]:
			print('YES')
		else:
			print('NO')


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


n = int(input())
discs = list(map(int, input().split()))
x = discs.index(max(discs))
first_list = discs[:x]
second_list = discs[x:]
second_list.reverse()
second_list.pop()
caseA = 0
caseB = 0
caseC = 0
if all((first_list[i] < first_list[i + 1] for i in range(len(first_list) - 1))):
	caseA = 1
if all((second_list[i] < second_list[i + 1] for i in range(len(second_list) - 1))):
	caseB = 1
discs.sort()
if all((discs[i] != discs[i + 1] for i in range(n - 1))):
	caseC = 1
if caseA and caseB and caseC:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
i = a.index(max(a))
f = True
j = i + 1
while j < n:
	if a[j] >= a[j - 1]:
		f = False
	j += 1
j = i - 1
while j >= 0:
	if a[j] >= a[j + 1]:
		f = False
	j -= 1
print('YES' if f else 'NO')


n = int(input())
l = list(map(int, input().split()))
k = l.index(n)
if l[:k] == sorted(l[:k]) and l[k + 1:] == sorted(l[k + 1:])[::-1]:
	print('YES')
else:
	print('NO')


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

def solve(a, n):
	first = False
	for i in range(1, n):
		if a[i - 1] > a[i] and (not first):
			first = True
		if first and a[i - 1] < a[i]:
			return False
	return True
print('Yes') if solve(a, n) else print('No')


import math
import os
import random
import re
import sys

def check(arr, n):
	flag = 0
	for i in range(n - 1):
		if arr[i] < arr[i + 1]:
			if flag == 0:
				flag += 1
			elif flag == -1:
				print('NO')
				return
		elif flag == 0 or flag == 1:
			flag = -1
	print('YES')
n = int(input())
arr = list(map(int, input().split()))
check(arr, n)


def sv():
	N = int(input())
	A = list(map(int, input().split()))
	dec = False
	for i in range(1, N):
		if dec:
			if A[i] > A[i - 1]:
				return False
		elif A[i] < A[i - 1]:
			dec = True
	return True
print('YES' if sv() else 'NO')


n = int(input())
A = [int(i) for i in input().split()]
x = max(A)
ind = A.index(x)
c = 0
arr1 = A[:ind]
if ind < n - 1:
	arr2 = A[ind + 1:]
	temp2 = sorted(arr2, reverse=True)
	if temp2 == arr2:
		c += 1
else:
	c += 1
if ind == 0:
	c += 1
else:
	temp1 = sorted(arr1)
	if temp1 == arr1:
		c += 1
if c == 2:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
big = l.index(n)
count = 0
lol = 0
for i in range(big):
	if l[i] > l[i + 1]:
		count += 1
		break
for i in range(big, n - 1):
	if l[i] < l[i + 1]:
		lol += 1
		break
if lol == 1 or count == 1:
	print('NO')
else:
	print('YES')


import sys
from collections import defaultdict
import math

def main():
	n = int(input())
	a = list(map(int, input().split()))
	pos = a.index(max(a))
	ok = True
	for i in range(pos):
		if a[i] > a[i + 1]:
			ok = False
			break
	if ok:
		for i in range(pos + 1, n):
			if a[i] > a[i - 1]:
				ok = False
				break
	print('YES' if ok else 'NO')
main()


from heapq import heappush, heappop
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)

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

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]
YN = ['YES', 'NO']

def bisect(ls, x):
	(l, r) = (0, len(ls))
	while r - l > 1:
		mid = (l + r) // 2
		if ls[mid] >= x:
			r = mid
		else:
			l = mid
	return l
q = 1
for _ in range(q):
	n = I()
	a = LI()
	m = max(a)
	mi = a.index(m)
	if a[:mi] == sorted(a[:mi]):
		if mi == n - 1:
			ans = 0
		elif a[mi + 1:] == sorted(a[mi + 1:])[::-1]:
			ans = 0
		else:
			ans = 1
	else:
		ans = 1
	print(YN[ans])


n = int(input())
a = list(map(int, input().split()))
i = 0
max = 0
for x in range(n):
	if a[x] > max:
		max = a[x]
		i = x
cur = 1
ans = 1
while cur <= i:
	if a[cur] < a[cur - 1]:
		ans = -1
		break
	cur += 1
if ans == 1:
	while cur < n - 1:
		if a[cur] < a[cur + 1]:
			ans = -1
			break
		cur += 1
if ans == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
w = 0
p = a.index(max(a))
for i in range(p + 1, n, 1):
	if a[i] > a[i - 1]:
		w = 1
		break
for i in range(0, p):
	if a[i] > a[i + 1]:
		w = 1
		break
if w:
	print('NO')
else:
	print('YES')


n = int(input())
l = [*map(int, input().split())]
i = l.index(n)
(left, right) = (i - 1, i + 1)
cur = n - 1
while left >= 0 or right < n:
	if left >= 0 and l[left] == cur:
		left -= 1
		cur -= 1
	elif right < n and l[right] == cur:
		right += 1
		cur -= 1
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
s = list(map(int, input().split()))
k = s.index(max(s))
for i in range(1, k + 1):
	if s[i - 1] > s[i]:
		print('No')
		exit()
for i in range(k, n - 1):
	if s[i] < s[i + 1]:
		print('No')
		exit()
print('YES')


nb_pillars = int(input())
wheels = [int(s) for s in input().split()]
maxi = wheels.index(max(wheels))
could_be = True
for i in range(maxi):
	could_be &= wheels[i] < wheels[i + 1]
for i in range(maxi, nb_pillars - 1):
	could_be &= wheels[i] > wheels[i + 1]
print(['NO', 'YES'][could_be])


n = int(input())
numbers = list(map(int, input().split()))
flag = 0
for i in range(1, len(numbers) - 1):
	if numbers[i] < numbers[i - 1] and numbers[i] < numbers[i + 1]:
		flag = 1
		print('NO')
		break
if flag == 0:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = [arr[i], i]
arr.sort(reverse=True)
l = arr[0][1]
r = arr[0][1]
for i in range(1, n):
	a = arr[i][1]
	if abs(l - a) > 1 and abs(r - a) > 1:
		print('NO')
		break
	else:
		l = min(l, a)
		r = max(r, a)
else:
	print('YES')


n = int(input())
a = (*map(int, input().split()),)
k = a.index(n)
print('YNEOS'[any((x > y for (x, y) in zip(a[:k], a[1:]))) | any((x < y for (x, y) in zip(a[k:], a[k + 1:])))::2])


n = int(input())
inp = input()
a = [int(ele) for ele in inp.split()]
b = a.copy()
b.sort()
b.reverse()
max = b[0]
single = [max]
top = 0
flag = 1
ind = a.index(max)
for i in range(ind - 1):
	if a[i] > a[i + 1]:
		print('NO')
		flag = 0
		break
if flag == 1:
	for i in range(ind + 1, len(a) - 1):
		if a[i] < a[i + 1]:
			print('NO')
			flag = 0
			break
if flag == 1:
	print('YES')


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
a = linput()
ans = True
mx = max(a)
for i in range(n):
	if a[i] == mx:
		break
	if a[i] > a[i + 1]:
		ans = False
if ans:
	while i < n - 1:
		if a[i] < a[i + 1]:
			ans = False
		i += 1
print('YES' if ans else 'NO')


n = int(input())
A = list(map(int, input().split()))
idx = A.index(n)
flag = True
for i in range(idx, 0, -1):
	if A[i - 1] >= A[i]:
		flag = False
		break
for i in range(idx, n - 1):
	if A[i] <= A[i + 1]:
		flag = False
		break
print('YES' if flag else 'NO')


n = int(input().strip())
pillars = list(map(int, input().split()))
increasing = True
prev = pillars[0]
can = True
for p in pillars[1:]:
	if p == prev:
		can = False
		break
	if increasing:
		if p < prev:
			increasing = False
	elif p > prev:
		can = False
		break
	prev = p
print('YES') if can else print('NO')


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	d[arr[i]] = i
index = arr.index(n)
(start, end) = (index, index)
flag = 0
for i in range(n - 1, 0, -1):
	if d[i] == start - 1:
		start -= 1
	elif d[i] == end + 1:
		end += 1
	else:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
data = list(map(int, input().split()))
k = data.index(max(data))
a1 = all((data[i] < data[i + 1] for i in range(k)))
a2 = all((data[i] > data[i + 1] for i in range(k)))
a3 = all((data[i] < data[i + 1] for i in range(k, n - 1)))
a4 = all((data[i] > data[i + 1] for i in range(k, n - 1)))
if a1 and a4 or (a2 and a3):
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(i) for i in input().split()]
m = 0
ind = -1
f1 = 0
f2 = 0
for i in range(n):
	if a[i] > m:
		ind = i
		m = a[i]
for i in range(ind):
	if a[i] >= a[i + 1]:
		f1 = 1
		break
for i in range(ind, n - 1):
	if a[i] <= a[i + 1]:
		f2 = 1
		break
if f1 == 1 or f2 == 1:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
pos = l.index(max(l))
flag = 0
for i in range(pos - 1):
	if l[i] > l[i + 1]:
		flag = 1
for i in range(pos, len(l) - 1):
	if l[i] < l[i + 1]:
		flag = 1
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
for i in range(len(l)):
	if l[i] == n:
		pos = i
c = 0
for i in range(pos, 0, -1):
	if l[i] < l[i - 1]:
		print('NO')
		exit()
for i in range(pos + 1, len(l) - 1):
	if l[i] < l[i + 1]:
		print('NO')
		exit()
print('YES')


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
indx = a.index(max(a))
ans = 'YES'
for i in range(indx + 1, n):
	if a[i] >= a[i - 1]:
		ans = 'NO'
		break
for i in reversed(range(indx - 1)):
	if a[i] >= a[i + 1]:
		ans = 'NO'
		break
print(ans)


def sign(x):
	if x > 0:
		return 1
	elif x < 0:
		return -1
	else:
		return 0
n = int(input())
x = list(map(int, input().split()))
a = len(set(x)) == n
b = [sign(u - v) for (u, v) in zip(x, x[1:])]
c = sorted(b) == b
print('Yes' if a and c else 'No')


def ans(a):
	for i in range(1, len(a) - 1):
		if a[i] < a[i - 1] and a[i] < a[i + 1]:
			return False
	return True
n = int(input())
l = list(map(int, input().split()))
print('YES' if ans(l) else 'NO')


from sys import stdin, stdout, exit
n = int(input())
a = list(map(int, stdin.readline().split()))
max_idx = a.index(n)
af = a[:max_idx]
ab = a[max_idx:]
if af == sorted(af) and ab == sorted(ab, reverse=True):
	print('YES')
else:
	print('NO')


n = int(input())
ss = [int(i) for i in input().split()]
if n == len(set(ss)):
	ind = ss.index(max(ss))
	temp = max(ss)
	k = 'YES'
	for i in range(ind + 1, n):
		if ss[i] < temp:
			temp = ss[i]
		else:
			k = 'NO'
			break
	if k == 'NO':
		print(k)
	else:
		temp = max(ss)
		for i in range(ind - 1, -1, -1):
			if ss[i] < temp:
				temp = ss[i]
			else:
				k = 'NO'
				break
		print(k)


def is_asc(li):
	ans = True
	for i in range(0, len(li) - 1):
		if li[i] > li[i + 1]:
			ans = False
			break
	return ans

def is_desc(li):
	ans = True
	for i in range(0, len(li) - 1):
		if li[i] < li[i + 1]:
			ans = False
			break
	return ans
n = int(input())
li = list(map(int, input().split()))
root = li.index(max(li))
a1 = is_asc(li[:root])
a2 = is_desc(li[root + 1:])
if a1 and a2:
	print('yes')
else:
	print('no')


x = int(input())
y = input()
y_ = y.split()
z = [int(d) for d in y_]
q = z.index(max(z))
a = z[:q]
b = z[q + 1:]
r = z[:q]
s = z[q + 1:]
a.sort()
b.sort(reverse=True)
if r == a and s == b:
	print('YES')
else:
	print('NO')


n = int(input())
a = list((int(x) for x in input().split()))
m = max(a)
i = a.index(m)
b = a[:i]
c = a[i + 1:]
d = sorted(b)
e = sorted(c, reverse=True)
if b == d and c == e:
	print('YES')
else:
	print('NO')


import sys
n = int(sys.stdin.readline())
a = [int(x) for x in sys.stdin.readline().strip().split()]
mx = max(a)
mx_pos = a.index(mx)
l = mx_pos - 1
r = mx_pos + 1
need = mx - 1
ans = 'YES'
while l != -1 or r != n:
	if l != -1 and a[l] == need:
		l -= 1
	elif r != n and a[r] == need:
		r += 1
	else:
		ans = 'NO'
		break
	need -= 1
print(ans)


n = input()
List = list(map(int, input().split()))
List2 = sorted(List)
out = 'YES'
I = List.index(List2[len(List2) - 1])
for i in range(I):
	if List[i] >= List[i + 1]:
		out = 'NO'
for i in range(I, len(List) - 1):
	if List[i] <= List[i + 1]:
		out = 'NO'
print(out)


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


n = int(input())
arr = input()
l = list(map(int, arr.split(' ')))
for i in range(1, len(l) - 1):
	if l[i] < l[i - 1] and l[i] < l[i + 1]:
		print('NO')
		exit(0)
print('YES')


import sys
input = sys.stdin.readline
n = int(input())
A = [int(i) for i in input().split()]
k = A.index(n)
flag = True
for i in range(1, n):
	if i <= k:
		if A[i] < A[i - 1]:
			flag = False
	elif A[i] > A[i - 1]:
		flag = False
print('Yes' if flag == True else 'No')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	mx_idx = a.index(max(a))
	ans = 'yes'
	for i in range(1, mx_idx, 1):
		if a[i - 1] >= a[i]:
			ans = 'no'
	for i in range(mx_idx + 1, n, 1):
		if a[i - 1] < a[i]:
			ans = 'no'
	print(ans)
solve()


import sys

def is_valid(ls):
	n = len(ls)
	k = ls.index(n)
	prev = 0
	for i in range(n):
		if i < k:
			if prev > ls[i]:
				return False
		if i > k:
			if prev < ls[i]:
				return False
		prev = ls[i]
	return True
n = int(sys.stdin.readline())
disk_ls = [int(i) for i in sys.stdin.readline().split()]
if is_valid(disk_ls):
	print('YES')
else:
	print('NO')


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
n = ii()
l = li()
m = l.index(n)
l2 = sorted(l[:m]) + [l[m]] + sorted(l[m + 1:], reverse=True)
if l == l2:
	print('YES')
else:
	print('NO')


n = int(input())
s = input().split()
s = list(s)
for i in range(n):
	s[i] = int(s[i])
c = 0
for i in range(1, n - 1):
	if s[i - 1] > s[i] and s[i] < s[i + 1]:
		print('no')
		break
	else:
		c += 1
if c == n - 2:
	print('yes')


def solve(nums):
	targetPiller = nums.index(max(nums))
	i = 0
	while i < targetPiller - 1:
		if nums[i] > nums[i + 1]:
			print('NO')
			return
		i += 1
	i = targetPiller + 1
	while i < len(nums) - 1:
		if nums[i] < nums[i + 1]:
			print('NO')
			return
		i += 1
	print('YES')
input()
nums = list(map(int, input().split()))
solve(nums)


n = int(input())
c = list(map(int, input().split()))
r = c.index(max(c))
l1 = c[:r]
l2 = c[r:]
l3 = sorted(l1)
l4 = sorted(l2)[::-1]
if l1 == l3 and l2 == l4:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
i = a.index(n)
print('YES') if a[:i] == sorted(a[:i]) and a[i + 1:] == sorted(a[i + 1:])[::-1] else print('NO')


n = int(input())
a = list(map(int, input().split()))
t = a.index(n)
b = True
for i in range(1, n):
	if i < t:
		if a[i] < a[i - 1]:
			b = False
	if i > t:
		if a[i] > a[i - 1]:
			b = False
if b:
	print('yes')
else:
	print('no')


n = int(input())
ar = list(map(int, input().split()))
m = max(ar)
ind = -1
for i in range(n):
	if ar[i] == m:
		ind = i
ans = 'YES'
a1 = []
a2 = []
for i in range(ind):
	a1.append(ar[i])
	a2.append(ar[i])
a2.sort()
for i in range(ind):
	if a1[i] != a2[i]:
		ans = 'NO'
a3 = []
a4 = []
for i in range(ind + 1, n):
	a3.append(ar[i])
	a4.append(ar[i])
a4.sort(reverse=True)
for i in range(len(a3)):
	if a3[i] != a4[i]:
		ans = 'NO'
print(ans)


n = int(input())
arr = list(map(int, input().split()))
prev = arr[0]
ind = len(arr)
for i in range(1, len(arr)):
	if prev < arr[i]:
		prev = arr[i]
	else:
		prev = arr[i]
		ind = i + 1
		break
for i in range(ind, len(arr)):
	if prev > arr[i]:
		prev = arr[i]
	else:
		print('NO')
		break
else:
	print('YES')


def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	center = -1
	for (i, v) in enumerate(arr):
		if v == n:
			center = i
			break
	for i in range(0, center):
		if arr[i] > arr[i + 1]:
			return False
	for i in range(center, n - 1):
		if arr[i] < arr[i + 1]:
			return False
	return True
if solve():
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
max = a[0]
maxp = 0
for i in range(n):
	if a[i] > max:
		maxp = i
		max = a[i]
i = maxp - 1
j = maxp + 1
flag = 0
current = max
while i >= 0 or j < n:
	if i >= 0 and j < n:
		if a[i] > a[j]:
			max = i
		else:
			max = j
		if a[max] >= current:
			flag = 1
			break
		elif max == i:
			current = a[i]
			i -= 1
		else:
			current = a[j]
			j += 1
	elif i >= 0:
		if a[i] >= current:
			flag = 1
			break
		else:
			current = a[i]
			i -= 1
	elif a[j] >= current:
		flag = 1
		break
	else:
		current = a[j]
		j += 1
if flag == 0:
	print('YES')
else:
	print('NO')


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
R = lambda : map(int, input().split())
n = int(input())
l = list(R())
max_no = max(l)
index_max = l.index(max_no)
flag = False
for i in range(1, index_max):
	if l[i] < l[i - 1]:
		flag = True
		break
for j in range(index_max + 1, n):
	if l[j] > l[j - 1]:
		flag = True
		break
if flag:
	print('NO')
else:
	print('YES')


n = int(input().strip())
nums = list(map(int, input().strip().split()))
has_dups = len(nums) > len(set(nums))
mx = nums.index(max(nums))
if has_dups or nums[:mx + 1] != sorted(nums[:mx + 1]) or nums[mx:] != sorted(nums[mx:], reverse=True):
	print('NO')
else:
	print('YES')


a = int(input())
v = True
d = [int(i) for i in input().split()]
m = d.index(a)
(l, r) = (d[0:m], d[-1:m:-1])
while l or r:
	if len(r) and r[-1] == a - 1:
		r.pop()
	elif len(l) and l[-1] == a - 1:
		l.pop()
	else:
		print('NO')
		exit()
	a -= 1
print('YES')


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(input())

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

def inpl_str():
	return list(input().split())
N = inp()
aa = inpl()
maxi = aa.index(N)
for i in range(maxi, N - 1):
	if aa[i] < aa[i + 1]:
		print('NO')
		return
for i in reversed(list(range(0, maxi))):
	if aa[i] > aa[i + 1]:
		print('NO')
		return
print('YES')


n = int(input())
a = list(map(int, input().split()))
check = False
i = 0
while i < n - 1:
	if a[i] < a[i + 1]:
		i += 1
	else:
		break
while i < n - 1:
	if a[i] > a[i + 1]:
		i += 1
	else:
		break
if i < n - 1:
	check = True
if check:
	print('NO')
else:
	print('YES')


n = int(input(''))
a = input('')
p = []
for i in a.split(' '):
	p.append(int(i))
count = 0
for i in range(1, p.index(max(p))):
	if p[i - 1] > p[i]:
		count = 1
		break
for i in range(p.index(max(p)) + 1, len(p)):
	if p[i - 1] < p[i]:
		count = 1
		break
if count == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(i) for i in input().split()]
if n > len(set(a)):
	print('NO')
else:
	(curr, verdict) = (a[0], True)
	if a[1] > curr:
		up = True
		down = False
		mark = n - 1
		for i in range(1, n):
			if a[i] < curr:
				up = False
				down = True
				mark = i
				break
			curr = a[i]
		for i in range(mark, n):
			if a[i] > curr:
				verdict = False
				break
			curr = a[i]
	else:
		down = True
		for i in range(1, n):
			if a[i] > curr:
				verdict = False
				break
			curr = a[i]
	if verdict:
		print('YES')
	else:
		print('NO')


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
a = LI()
(f1, f2, f3) = (1, 1, 1)
for i in range(0, n - 1):
	if a[i] < a[i + 1]:
		f1 = 0
		break
for i in range(0, n - 1):
	if a[i] > a[i + 1] and f2 == 1:
		f2 = 2
	if f2 == 2 and a[i] < a[i + 1]:
		f2 = 0
		break
for i in range(0, n - 1):
	if a[i] > a[i + 1]:
		f3 = 0
		break
if f1 or (f2 == 1 or f2 == 2) or f3:
	print('YES')
else:
	print('NO')


n = int(input())
a = (*map(int, input().split()),)
x = i = 0
j = n - 1
while i < j:
	if x < a[i] < a[j]:
		x = a[i]
		i += 1
	elif x < a[j] < a[i]:
		x = a[j]
		j -= 1
	else:
		print('NO')
		exit()
print('YES')


pillar = int(input())
pillars = list(map(int, input().split()))
asc = True
pos = True
for i in range(pillar - 1):
	if asc:
		if pillars[i] < pillars[i + 1]:
			continue
		else:
			asc = False
	elif pillars[i] > pillars[i + 1]:
		continue
	else:
		pos = False
if pos:
	print('Yes')
else:
	print('No')


n = int(input())
s = list(map(int, input().split()))
max1 = 0
for i in range(len(s)):
	if s[i] > s[max1]:
		max1 = i
left = True
right = True
for i in range(max1):
	if s[i] < s[i + 1]:
		continue
	else:
		left = False
		break
if not left:
	print('No')
else:
	for i in range(max1, len(s) - 1):
		if s[i] > s[i + 1]:
			continue
		else:
			right = False
			break
	if not right:
		print('No')
	else:
		print('Yes')


input()
a = list(map(int, input().split()))
b = []
c = []
e = a.index(max(a))
b.append(a[:e])
c.append(a[e:len(a)])
d = sorted(b[0], reverse=False)
if b[0] == d and c[0] == sorted(c[0], reverse=True):
	print('YES')
else:
	print('NO')


n = int(input())
A = list(map(int, input().split()))
maximum = A[0]
idx = 0
for i in range(1, n):
	if A[i] > maximum:
		maximum = A[i]
		idx = i
l = idx - 1
r = idx + 1
ans = True
base = A[idx]
while l >= 0 and r < n:
	if A[l] > A[r]:
		if base < A[l]:
			ans = False
			break
		base = A[l]
		l -= 1
	else:
		if base < A[r]:
			ans = False
			break
		base = A[r]
		r += 1
if l >= 0:
	while l >= 0:
		if base < A[l]:
			ans = False
			break
		base = A[l]
		l -= 1
elif r < n:
	while r < n:
		if base < A[r]:
			ans = False
			break
		base = A[r]
		r += 1
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
max1 = l.index(n)
for i in range(1, n):
	if i <= max1:
		if l[i - 1] < l[i]:
			continue
		else:
			print('NO')
			exit()
	elif l[i] < l[i - 1]:
		continue
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
array = list(map(int, input().split()))
ind = array.index(max(array))
(i, j) = (ind - 1, ind + 1)
now = array[ind]
while i != -1 or j != n:
	if i == -1:
		if array[j] < now:
			now = array[j]
			j += 1
		else:
			print('NO')
			exit(0)
	elif j == n:
		if array[i] < now:
			now = array[i]
			i -= 1
		else:
			print('NO')
			exit(0)
	elif array[i] > array[j]:
		if array[i] < now:
			now = array[i]
			i -= 1
		else:
			print('NO')
			exit(0)
	elif array[j] < now:
		now = array[j]
		j += 1
	else:
		print('NO')
		exit(0)
print('YES')


input()
X = list(map(int, input().split()))
Left = X[:X.index(max(X))]
Right = X[X.index(max(X)):]
print('YES' if sorted(Left) == Left and sorted(Right, reverse=True) == Right else 'NO')


n = int(input())
arr = [int(x) for x in input().split()]
temp = max(arr)
ind = arr.index(temp)
flag = 1
i = 0
arr2 = []
arr3 = []
for j in range(ind):
	arr2.append(arr[j])
for j in range(ind + 1, n):
	arr3.append(arr[j])
arr2.sort()
arr3.sort(reverse=True)
flag = 1
for j in range(ind):
	if arr2[j] != arr[j]:
		flag = 0
		break
if flag == 1:
	for j in range(ind + 1, n):
		if arr3[j - ind - 1] != arr[j]:
			flag = 0
			break
if flag == 1:
	print('YES\n')
else:
	print('NO\n')


n = int(input())
arr = [int(x) for x in input().split()]
ans = True
for i in range(1, n - 1):
	if arr[i] < arr[i + 1] and arr[i] < arr[i - 1]:
		ans = False
print('yes' if ans else 'no')


n = int(input())
l = list(map(int, input().split()))
big = l[0]
ptr = 0
for i in range(1, len(l)):
	if l[i] > big:
		big = l[i]
		ptr = i
flag = 0
if ptr == len(l) - 1:
	if l[:ptr] == sorted(l[:ptr]):
		flag = 1
elif ptr == 0:
	if l[ptr + 1:] == sorted(l[ptr + 1:], reverse=True):
		flag = 1
elif l[:ptr] == sorted(l[:ptr]) and l[ptr + 1:] == sorted(l[ptr + 1:], reverse=True):
	flag = 1
if flag == 0:
	print('NO')
elif flag == 1:
	print('YES')


def main():
	n = int(input())
	a_list = list(map(int, input().split(' ')))
	max_a = max(a_list)
	max_a_i = a_list.index(max_a)
	ok = True
	before = a_list[0]
	for i in range(1, max_a_i):
		cur = a_list[i]
		if before >= cur:
			return 'NO'
		before = cur
	before = a_list[-1]
	for i in range(n - 2, max_a_i, -1):
		cur = a_list[i]
		if before >= cur:
			return 'NO'
		before = cur
	return 'YES'
out = main()
print(out)


import sys
import math
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
ind = arr.index(max(arr))
arr1 = list(arr[:ind])
arr2 = list(arr[ind + 1:])
arr2.sort(reverse=True)
arr1.sort()
if arr1 == arr[:ind] and arr2 == arr[ind + 1:]:
	print('YES')
else:
	print('NO')


n = int(input())
a = [0] + list(map(int, input().split())) + [0]
index = 0
m = 0
for (i, e) in enumerate(a):
	if e > m:
		m = e
		index = i
p1 = index - 1
p2 = index + 1
works = True
while p1 > 0 or p2 < n + 1:
	if a[p1] > a[p2]:
		if a[p1] < m:
			m = a[p1]
			p1 -= 1
		else:
			works = False
			break
	elif a[p2] < m:
		m = a[p2]
		p2 += 1
	else:
		works = False
		break
if works:
	print('yes')
else:
	print('no')


n = int(input())
a = list(map(int, input().split()))
if a == sorted(a) or a == sorted(a, reverse=True):
	print('YES')
else:
	out = True
	for i in range(n):
		if a[i] > a[i + 1]:
			break
	for j in range(i, n - 1):
		if a[j] < a[j + 1]:
			out = False
			break
	print('YES' if out else 'NO')


k = f = 0
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1, n):
	if a[i] < a[i - 1]:
		f = 1
	if a[i] > a[i - 1] and f != 0:
		print('NO')
		k = 1
	if k == 1:
		break
if k == 0:
	print('YES')


n = int(input())
arr = list(map(int, input().split()))
ind = arr.index(max(arr))
(arr1, arr2) = (arr[:ind], arr[ind + 1:])
if arr1 == list(sorted(arr1)) and arr2 == list(reversed(sorted(arr2))):
	print('YES')
else:
	print('NO')


n = int(input())
x = list(map(int, input().split()))
flag = True
max_val = max(x)
max_pos = x.index(max_val)
for i in range(max_pos + 1):
	if i < max_pos - 1 and x[i + 1] < x[i]:
		flag = False
for i in range(max_pos, n + 1):
	if i < n - 1 and x[i + 1] > x[i]:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


a = int(input())
b = list(map(int, input().split()))
i = 1
while i < a - 1:
	if b[i - 1] > b[i] and b[i] < b[i + 1]:
		exit(print('NO'))
	i += 1
print('YES')


s = int(input())
l = [int(x) for x in input().split()]
m = max(l)
index = l.index(m)
ans = 'yes'
for i in range(index, len(l)):
	if i == len(l) - 1:
		break
	elif l[i] < l[i + 1]:
		ans = 'no'
for i in range(index, 0, -1):
	if l[i] < l[i - 1]:
		ans = 'no'
print(ans)


def pd(a, mid):
	L = a[:mid][::-1]
	R = a[mid + 1:]
	k = a[mid]
	i = j = 0
	while i < len(L) and j < len(R):
		if L[i] < R[j]:
			if k > R[j]:
				k = R[j]
				j += 1
			else:
				return 0
		elif L[i] > R[j]:
			if k > L[i]:
				k = L[i]
				i += 1
			else:
				return 0
		else:
			return 0
	if i == len(L):
		if R[j:] == sorted(R[j:])[::-1]:
			return 1
	if j == len(R):
		if L[i:] == sorted(L[i:])[::-1]:
			return 1
	return 0
n = int(input())
l = list(map(int, input().split()))
k = l.index(max(l))
print('YNEOS'[not pd(l, k)::2])


import sys, collections
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
permu = [i for i in range(1, n + 1)]
if sorted(arr) != permu:
	print('NO')
else:
	idx = arr.index(max(arr))
	i = idx - 1
	j = idx + 1
	top = arr[idx]
	while i > -1 or j < n:
		if i < 0:
			if arr[j] == top - 1:
				top = arr[j]
				j += 1
			else:
				break
		elif j > n - 1:
			if arr[i] == top - 1:
				top = arr[i]
				i -= 1
			else:
				break
		elif arr[i] == top - 1:
			top = arr[i]
			i -= 1
		elif arr[j] == top - 1:
			top = arr[j]
			j += 1
		else:
			break
	if i <= -1 and j >= n:
		print('YES')
	else:
		print('NO')


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


n = int(input())
a = list(map(int, input().split()))
i = a.index(n)
l = i - 1
r = i + 1
ans = 'YES'
for i in range(1, n):
	if l >= 0 and a[l] == n - i:
		l -= 1
	elif r < n and a[r] == n - i:
		r += 1
	else:
		ans = 'NO'
print(ans)


def check(l):
	for i in range(1, len(l)):
		if l[i] < l[i - 1]:
			return False
	return True
n = int(input())
a = [int(i) for i in input().split()]
max = max(a)
max_pos = a.index(max)
left = a[0:max_pos]
right = a[-1:max_pos:-1]
if check(left) and check(right):
	print('YES')
else:
	print('NO')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	n = Int()
	a = List()
	s = 0
	for i in range(n - 2):
		if a[i] > a[i + 1] < a[i + 2]:
			s += 1
	if s == 0:
		print('YES')
	else:
		print('NO')
solution()


n = int(input())
a = list(map(int, input().split()))
f = 0
x = a.index(max(a))
i = x - 1
j = x + 1
while i >= 0 or j < n:
	if i >= 0:
		u = a[i]
	if j < n:
		v = a[j]
	if i >= 0 and a[x] - u == 1:
		x = i
		i -= 1
	elif j < n and a[x] - v == 1:
		x = j
		j += 1
	else:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')


n = int(input())
A = list(map(int, input().split()))
M = max(A)
cnt = 0
j = -1
for (i, a) in enumerate(A):
	if a == M:
		cnt += 1
		j = i
if cnt >= 2:
	print('NO')
	exit()
for i in range(min(0, j - 1), j - 1):
	if A[i] >= A[i + 1]:
		print('NO')
		exit()
for i in range(j, n - 1):
	if A[i] <= A[i + 1]:
		print('NO')
		exit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
largest_index = 0
largest_value = a[0]
for i in range(len(a)):
	if a[i] > largest_value:
		largest_value = a[i]
		largest_index = i
currPtr = 0
b = True
while currPtr < largest_index:
	if a[currPtr + 1] <= a[currPtr]:
		b = False
		break
	currPtr += 1
c = True
currPtr = largest_index
while currPtr < len(a) - 1:
	if a[currPtr + 1] >= a[currPtr]:
		c = False
		break
	currPtr += 1
if b and c:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
ind = a.index(max(a))
pos = True
for i in range(1, ind + 1):
	if a[i] < a[i - 1]:
		pos = False
		break
if pos:
	for i in range(ind + 1, n):
		if a[i] > a[i - 1]:
			pos = False
			break
	if pos:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


n = int(input())
a = [(i, int(val)) for (i, val) in enumerate(input().split())]
a.sort(key=lambda x: -x[1])
leftmost_none = rightmost_none = a[0][0]
for i in range(1, n):
	if a[i][0] < a[0][0]:
		if leftmost_none - a[i][0] > 1:
			print('NO')
			exit()
		else:
			leftmost_none = a[i][0]
	elif a[i][0] > a[0][0]:
		if a[i][0] - rightmost_none > 1:
			print('NO')
			exit()
		else:
			rightmost_none = a[i][0]
print('YES')


n = int(input())
l = list(map(int, input().split()))
i = l.index(max(l))
l1 = l[0:i]
l2 = l[i + 1:n]
if sorted(l1) == l1:
	if sorted(l2, reverse=True) == l2:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
m = 0
for i in range(n):
	if a[i] > m:
		m = a[i]
		mi = i
forw = a[mi:]
back = a[:mi]
flag = True
if forw:
	t1 = forw[0]
	for i in range(1, len(forw)):
		if forw[i] > t1:
			flag = False
		else:
			t1 = forw[i]
if back:
	t1 = back[-1]
	for i in range(len(back) - 1, -1, -1):
		if back[i] > t1:
			flag = False
		else:
			t1 = back[i]
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
arr = [int(x) for x in input().split()]
rev = sorted(arr, reverse=True)
ind = arr.index(rev[0])
i = ind - 1
j = ind + 1
t = 1
flag = True
while i > -1 or j < n:
	if i > -1 and arr[i] == rev[t]:
		t += 1
		i -= 1
	elif j < n and arr[j] == rev[t]:
		t += 1
		j += 1
	else:
		flag = False
		break
print('YES' if flag else 'NO')


w = int(input())
a = list(map(int, input().split()))
e = max(a)
t = 0
t1 = 0
if e == a[0]:
	t = 1
for j in range(1, w):
	if t == 0:
		if a[j] < a[j - 1]:
			t1 = 1
			break
	elif a[j] > a[j - 1]:
		t1 = 1
		break
	if a[j] == e:
		t = 1
if t1 == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(i) for i in input().split()]
if len(list(set(a))) != len(a):
	print('NO')
elif len(a) == 1:
	print('YES')
else:
	m = max(a)
	d = a.index(m)
	cur = m
	i = d - 1
	j = d + 1
	f = 1
	while i >= 0 and j < n:
		if max(a[i], a[j]) >= cur:
			f = 0
			break
		if a[i] > a[j]:
			cur = a[i]
			i -= 1
		else:
			cur = a[j]
			j += 1
	if i < 0:
		while j < n:
			if a[j] >= cur:
				f = 0
				break
			cur = a[j]
			j += 1
	elif j >= n:
		while i >= 0:
			if a[i] >= cur:
				f = 0
				break
			cur = a[i]
			i -= 1
	if f == 1:
		print('YES')
	else:
		print('NO')


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
a = li()
pos = a.index(n)
for i in range(pos):
	if a[i] >= a[i + 1]:
		exit(print('NO'))
for i in range(pos + 1, n, 1):
	if a[i - 1] <= a[i]:
		exit(print('NO'))
print('YES')


n = int(input())
l = [int(s) for s in input().split()]
re1 = 0
re2 = 0
for i in range(len(l)):
	if l[i] == n:
		re1 = i - 1
		re2 = i + 1
te = n - 1
fl = 0
while te != 0:
	if re1 >= 0:
		if l[re1] == te:
			te -= 1
			re1 -= 1
			continue
	if re2 < n:
		if l[re2] == te:
			te -= 1
			re2 += 1
			continue
	print('NO')
	fl = 1
	break
if fl == 0:
	print('YES')


ll = lambda : list(map(int, input().split()))
testcases = 1
for testcase in range(testcases):
	[n] = ll()
	a = ll()
	x = a.index(n)
	if a[0:x] == sorted(a[0:x]) and a[x + 1:n] == sorted(a[x + 1:n], reverse=True):
		print('YES')
	else:
		print('NO')


n = int(input())
a = [int(i) for i in input().split()]
idx = a.index(max(a))
if a[:idx] == sorted(a[:idx]) and a[idx + 1:] == sorted(a[idx + 1:], reverse=True):
	print('YES')
else:
	print('NO')


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


n = int(input())
A = list(map(int, input().split()))
x = A.index(n)
l = x - 1
r = x + 1
now = n - 1
ans = 'YES'
while l >= 0 or r < n:
	if l < 0:
		if A[r] == now:
			now -= 1
			r += 1
		else:
			ans = 'NO'
			break
	elif r >= n:
		if A[l] == now:
			l -= 1
			now -= 1
		else:
			ans = 'NO'
			break
	elif A[l] == now:
		l -= 1
		now -= 1
	elif A[r] == now:
		r += 1
		now -= 1
	else:
		ans = 'NO'
		break
print(ans)


n = int(input())
a = list(map(int, input().split()))
ind = 0
max = 0
a_len = len(a)
for i in range(n):
	if a[i] > max:
		max = a[i]
		ind = i
for i in range(0, ind):
	if a[i] < a[i + 1]:
		continue
	else:
		print('No')
		exit(0)
for i in range(a_len - 1, ind, -1):
	if a[i] < a[i - 1]:
		continue
	else:
		print('No')
		exit(0)
print('Yes')


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
ind = -1
mx = -1
for i in range(n):
	if s[i] > mx:
		mx = s[i]
		ind = i
r = ind - 1
l = ind + 1
x = mx
while r > -1 or l < n:
	aux = x
	if r > -1 and l < n:
		if s[r] > s[l] and s[r] < x:
			x = s[r]
			r -= 1
		elif s[l] < x:
			x = s[l]
			l += 1
	elif r > -1:
		if s[r] < x:
			x = s[r]
			r -= 1
	elif l < n:
		if s[l] < x:
			x = s[l]
			l += 1
	if aux == x:
		break
if l == n and r == -1 and (x == min(s)):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
rev = [-1] * (n + 1)
for (i, j) in enumerate(a):
	rev[j] = i
mx = max(a)
l = a.index(mx)
r = l
for i in range(n - 1, 0, -1):
	idx = rev[i]
	if idx == l - 1:
		l -= 1
	elif idx == r + 1:
		r += 1
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
up = True
prev = 0
for el in a:
	if el > prev or prev == 0:
		if not up:
			print('no')
			exit()
	else:
		up = False
	prev = el
print('yes')


def solve():
	n = int(input())
	disks = list(map(int, input().split()))
	max_r = max(disks)
	met_r = False
	for i in range(n - 1):
		met_r |= disks[i] == max_r
		if not met_r:
			if disks[i] > disks[i + 1]:
				return 'NO'
		elif disks[i] < disks[i + 1]:
			return 'NO'
	return 'YES'
print(solve())


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


F = lambda : int(input())
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
n = F()
l = L()
i = l.index(max(l))
if l[:i] == sorted(l[:i]) and l[i + 1:] == sorted(l[i + 1:], reverse=True):
	print('YES')
else:
	print('NO')


x = int(input())
y = list(map(int, input().split()))
for i in range(0, y.index(x)):
	if y[i] >= y[i + 1]:
		print('NO')
		exit()
for i in range(x - 1, y.index(x), -1):
	if y[i] >= y[i - 1]:
		print('NO')
		exit()
print('YES')


def main():
	n = int(input())
	a = [int(s) for s in input().split()]
	m = max(a)
	i = a.index(m)
	sol = 'YES'
	for (j, x) in enumerate(a):
		if j < i and x > a[j + 1]:
			sol = 'NO'
			break
		if j > i and x > a[j - 1]:
			sol = 'NO'
			break
	print(sol)
main()


class Node:

	def __init__(self, val: int, i: int, prev, next):
		self.val = val
		self.prev = prev
		self.next = next
		self.i = i

	def delete(self):
		if self.prev:
			self.prev.next = self.next
		if self.next:
			self.next.prev = self.prev
from collections import deque
n = int(input())
data = list(map(int, input().split()))
maxNode = None
startNode = Node(data[0], 0, None, None)
currentNode = startNode
for i in range(1, len(data)):
	currentNode.next = Node(data[i], i, currentNode, None)
	currentNode = currentNode.next
maxNode = startNode
currentNode = startNode
while currentNode:
	if currentNode.val > maxNode.val:
		maxNode = currentNode
	currentNode = currentNode.next
while maxNode.prev or maxNode.next:
	if maxNode.prev and maxNode.prev.val == maxNode.val - 1:
		maxNode = maxNode.prev
		maxNode.next.delete()
	elif maxNode.next and maxNode.next.val == maxNode.val - 1:
		maxNode = maxNode.next
		maxNode.prev.delete()
	else:
		print('no')
		break
else:
	print('yes')


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


n = int(input())
a = list(map(int, input().split()))
Max = a.index(max(a))
if a[:Max] == sorted(a[:Max]) and a[Max:] == sorted(a[Max:], reverse=True):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
basic = 0
index = -1
for i in range(n):
	if a[i] > basic:
		basic = a[i]
		index = i
left = index
right = index
k = basic
t = True
for i in range(n):
	leftside = True
	rightside = True
	if left >= 1:
		if a[left - 1] == k - 1:
			left -= 1
		else:
			leftside = False
	else:
		leftside = False
	if right <= n - 2:
		if a[right + 1] == k - 1:
			right += 1
		else:
			rightside = False
	else:
		rightside = False
	if not leftside and (not rightside):
		t = False
		break
	k -= 1
if left == 0 and right == n - 1:
	t = True
if t:
	print('YES')
else:
	print('NO')


n = int(input())
ln = [int(i) for i in input().split(' ')]
m = ln.index(n)
wds = ['NO', 'YES']
f = True
for i in range(m - 1, -1, -1):
	if ln[i] > ln[i + 1]:
		f = False
for i in range(m + 1, len(ln)):
	if ln[i] > ln[i - 1]:
		f = False
print(wds[f])


n = int(input())
a = list(map(int, input().split()))
i = 1
while i < n and a[i] > a[i - 1]:
	i = i + 1
if i == n:
	print('YES')
	exit()
c = i - 1
i = i + 1
while i < n and a[i - 1] > a[i]:
	i = i + 1
if i == n:
	print('YES')
else:
	print('NO')


n = int(input())
s = list(map(int, input().split()))
f = 0
for i in range(1, n):
	if f == 0 and s[i] > s[i - 1]:
		pass
	elif f == 0 and s[i] < s[i - 1]:
		f = 1
	elif f == 1 and s[i] < s[i - 1]:
		pass
	else:
		print('NO')
		exit(0)
print('Yes')


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


h = int(input())
n = h
numbers = [int(i) for i in input().split()]
index1 = 0
for i in range(n):
	if numbers[i] == n:
		index1 = i
		break
index = index1
count2 = 1
count3 = 1
while True:
	if index + count2 >= n and index - count3 < 0:
		print('YES')
		break
	if index + count2 >= n:
		index2 = index - count3
		if numbers[index] < numbers[index2]:
			print('NO')
			exit()
		numbers[index] = numbers[index2]
		count3 += 1
		continue
	elif index - count3 < 0:
		index1 = index + count2
		if numbers[index] < numbers[index1]:
			print('NO')
			break
		numbers[index] = numbers[index1]
		count2 += 1
		continue
	index1 = index + count2
	index2 = index - count3
	maximal = max(numbers[index1], numbers[index2])
	if maximal > numbers[index]:
		print('NO')
		break
	numbers[index] = maximal
	if maximal == numbers[index1]:
		count2 += 1
	else:
		count3 += 1


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


t = int(input())
a = list(map(int, input().split()))
m = max(a)
b = True
for i in range(t - 1):
	if a[i] == m:
		break
	if a[i] < a[i + 1]:
		pass
	else:
		b = False
		break
ind = a.index(m)
for i in range(ind, t - 1):
	if a[i] > a[i + 1]:
		c = 1
	else:
		b = False
		break
if b:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
maxval = max(arr)
maxindex = -1
for i in range(n):
	if arr[i] == maxval:
		maxindex = i
		break
flag = 0
temp = maxval
for i in range(maxindex - 1, -1, -1):
	if temp <= arr[i]:
		flag = 1
		break
	else:
		temp = arr[i]
temp = maxval
for i in range(maxindex + 1, n):
	if arr[i] >= temp:
		flag = 1
		break
	else:
		temp = arr[i]
if flag == 0:
	print('YES')
else:
	print('NO')


IN = input
rint = lambda : int(IN())
rmint = lambda : map(int, IN().split())
rlist = lambda : list(rmint())
n = rint()
a = rlist()
l = 0
while l + 1 < n and a[l + 1] > a[l]:
	l += 1
r = n - 1
while r - 1 >= 0 and a[r - 1] > a[r]:
	r -= 1
if l + 1 >= r:
	print('YES')
else:
	print('NO')


n = int(input())
v = [int(i) for i in input().split()]
where = -1
for i in range(0, n):
	if v[i] == n:
		where = i
		break
if v[:where] == sorted(v[:where]) and v[where + 1:] == sorted(v[where + 1:], reverse=True):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
counter = 0
for i in range(n - 2):
	if a[i] < a[i + 1] > a[i + 2]:
		counter += 1
	elif a[i] > a[i + 1] < a[i + 2]:
		counter += 10
	if counter >= 2:
		break
if counter >= 2:
	print('NO')
else:
	print('YES')


def int_list():
	return [int(c) for c in input().split()]

def int1():
	return int(input())

def str_list():
	return [c for c in input().split()]

def str1():
	return input()
n = int1()
l = int_list()
cnt = [0] * n
mx = 0
mx_ind = -1
for i in range(len(l)):
	cnt[l[i] - 1] += 1
	if mx < l[i]:
		mx = l[i]
		mx_ind = i
if max(cnt) > 1:
	print('NO')
else:
	print_no = False
	left = l[:mx_ind]
	right = []
	right_ok = False
	if mx_ind < n - 1:
		right_ok = True
		right = l[mx_ind + 1:]
	if len(left) >= 2:
		for i in range(len(left) - 1):
			if left[i] > left[i + 1]:
				print_no = True
	if right_ok and len(right) >= 2:
		for j in range(len(right) - 1):
			if right[j] < right[j + 1]:
				print_no = True
if print_no:
	print('NO')
else:
	print('YES')


import itertools

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

def output_list(v):
	print(' '.join((str(x) for x in v)))

def main():
	n = int(input())
	a = input_ints()
	j = a.index(max(a))
	f = True
	for i in range(j, n - 1):
		if a[i] < a[i + 1]:
			f = False
	for i in range(j):
		if a[i] > a[i + 1]:
			f = False
	print('Yes' if f else 'No')
main()


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


import copy
n = int(input())
s = input()
arr = s.split(' ')
maxm = 0
index = 0
for i in range(n):
	arr[i] = int(arr[i])
	if arr[i] > maxm:
		maxm = arr[i]
		index = i
i = index - 1
j = index + 1
ans = ''
arp = copy.deepcopy(arr)
arp.sort()
ij = n - 2
while i >= 0 or j <= n - 1:
	if i >= 0 and arr[i] == arp[ij]:
		if arr[i] == arr[index]:
			ans = 'NO'
			break
		else:
			arr[index] = arr[i]
			i = i - 1
			ij = ij - 1
	elif j <= n - 1 and arr[j] == arp[ij]:
		if arr[j] == arr[index]:
			ans = 'NO'
			break
		else:
			arr[index] = arr[j]
			j = j + 1
			ij = ij - 1
	else:
		ans = 'NO'
		break
if ans == 'NO':
	print(ans)
else:
	print('YES')


n = int(input())
a = [int(u) for u in input().split()]
dec = 0
for i in range(n - 1):
	if dec == 1:
		if a[i] < a[i + 1]:
			print('NO')
			exit()
	if a[i] > a[i + 1]:
		dec = 1
print('YES')


N = int(input())
a = list(map(int, list(input().rstrip().split())))
M = max(a)
m = min(a)
ok = True
for i in range(len(a)):
	if i == 0:
		if a[i] > a[i + 1] and a[i] < M:
			ok = False
			break
	elif i == len(a) - 1:
		if a[i] > a[i - 1] and a[i] < M:
			ok = False
			break
	elif a[i] > a[i - 1] and a[i] > a[i + 1] and (a[i] < M):
		ok = False
		break
if ok:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
mid = arr.index(n)
i = mid - 1
while i >= 1:
	if arr[i - 1] > arr[i]:
		print('NO')
		exit()
	i -= 1
i = mid + 1
while i <= n - 2:
	if arr[i] < arr[i + 1]:
		print('NO')
		exit()
	i += 1
print('YES')


import sys
input = lambda : sys.stdin.readline().strip()
n = int(input())
left = {}
right = {}
ls = list(map(int, input().split()))
for i in range(1, n - 1):
	left[i] = i - 1
	right[i] = i + 1
left[0] = None
right[n - 1] = None
left[n - 1] = n - 2
right[0] = 1
index = {}
for i in range(n):
	index[ls[i]] = i
for i in range(n, 1, -1):
	if left[index[i]] == index[i - 1]:
		right[index[i - 1]] = right[index[i]]
		left[right[index[i]]] = index[i - 1]
	elif right[index[i]] == index[i - 1]:
		left[index[i - 1]] = left[index[i]]
		right[left[index[i]]] = index[i - 1]
	else:
		print('NO')
		break
else:
	print('YES')


def check(n, lst):
	i = 0
	while i + 1 < n and lst[i + 1] > lst[i]:
		i += 1
	while i + 1 < n and lst[i + 1] < lst[i]:
		i += 1
	if i == n - 1:
		return 'YES'
	return 'NO'
m = int(input())
a = [int(j) for j in input().split()]
print(check(m, a))


n = int(input())
dat = list(map(int, input().split()))
m = max(dat)
res = True
asc = True
cur = 0
for i in range(n):
	if dat[i] == m:
		cur = dat[i]
		asc = False
		continue
	if asc:
		if cur >= dat[i]:
			res = False
		else:
			pass
	elif cur <= dat[i]:
		res = False
	else:
		pass
	cur = dat[i]
print('YES' if res else 'NO')


n = int(input())
a = list(map(int, input().split()))
kq = 1
t = a.index(n)
for i in range(t - 1):
	if a[i] > a[i + 1]:
		kq = 0
		break
if kq == 1:
	for i in range(t + 1, n - 1):
		if a[i] < a[i + 1]:
			kq = 0
			break
	if kq == 0:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = 1

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	maxi = max(l[:])
	maxind = l.index(maxi)
	maxi = 0
	flag = 'YES'
	for i in range(maxind + 1):
		if l[i] > maxi:
			maxi = l[i]
		else:
			flag = 'NO'
			break
	maxi = 0
	for i in range(n - 1, maxind - 1, -1):
		if l[i] > maxi:
			maxi = l[i]
		else:
			flag = 'NO'
	return flag
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(solve())


N = int(input())
A = [int(a) for a in input().split()]
ma = max(A)
mai = sum([i for i in range(N) if A[i] == ma])
print('NO' if sum([(A[i] > A[i + 1]) * (i < mai) + (A[i] < A[i + 1]) * (i > mai) for i in range(N - 1)]) else 'YES')


n = int(input())
a = list(map(int, input().split()))
j = a.index(max(a))
flag = True
for i in range(n - 1):
	if i == j:
		continue
	elif i < j:
		if a[i] >= a[i + 1]:
			flag = False
			break
	elif a[i] <= a[i + 1]:
		flag = False
		break
print('YES' if flag else 'NO')


t = 1
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	flag = 1
	for i in range(1, len(l) - 1):
		if l[i - 1] > l[i] and l[i] < l[i + 1]:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
a = list(map(int, input().split()))
highestElement = max(a)
fwdHighElement = 0
bkHighElement = 0
highEleIndex = a.index(highestElement)
FlagFwd = 0
FlagBkwd = 0
if highEleIndex == len(a) - 1:
	for i in range(0, len(a) - 1):
		if a[i] < a[i + 1]:
			Flag = 1
		else:
			Flag = 0
			break
	if Flag == 1:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
else:
	for i in range(highEleIndex, len(a) - 1):
		if a[i] > a[i + 1]:
			FlagFwd = 1
		else:
			FlagFwd = 0
			break
if highEleIndex == 0:
	for i in range(0, len(a) - 1):
		if a[i] > a[i + 1]:
			Flag = 1
		else:
			Flag = 0
			break
	if Flag == 1:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
else:
	for i in range(0, highEleIndex - 1):
		if a[i] < a[i + 1]:
			FlagBkwd = 1
		else:
			FlagBkwd = 0
			break
if FlagFwd == 1 and FlagBkwd == 1:
	print('YES')
else:
	print('NO')


n = int(input())
u = list(map(int, input().split()))
if n < 3:
	print('YES')
	exit()
if u[0] != n and u[0] > u[1]:
	print('NO')
	exit()
if u[n - 1] != n and u[n - 1] > u[n - 2]:
	print('NO')
	exit()
for i in range(1, n - 1):
	if u[i] == n:
		continue
	if u[i] > max(u[i - 1], u[i + 1]):
		print('NO')
		exit()
print('YES')


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


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


input()
a = list(map(int, input().split()))
ma = max(a)
ma_i = a.index(ma)
if a[:ma_i] == sorted(a[:ma_i]) and a[ma_i + 1:] == sorted(a[ma_i + 1:], reverse=True):
	print('YES')
else:
	print('NO')


n = int(input())
nums = list(map(int, input().split()))
ind_max = nums.index(n)
if ind_max == 0:
	for i in range(n - 1):
		if nums[i] < nums[i + 1]:
			print('NO')
			raise SystemExit
	print('YES')
	raise SystemExit
elif ind_max == n - 1:
	for i in range(n - 1):
		if nums[i] > nums[i + 1]:
			print('NO')
			raise SystemExit
	print('YES')
	raise SystemExit
else:
	for i in range(ind_max - 1):
		if nums[i] > nums[i + 1]:
			print('NO')
			raise SystemExit
	for i in range(ind_max, n - 1):
		if nums[i] < nums[i + 1]:
			print('NO')
			raise SystemExit
print('YES')


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


n = int(input())
INF = 10 ** 9
disks = list(map(int, input().split()))
maxdisk = 0
cur = 0
for i in range(n):
	if disks[i] > maxdisk:
		maxdisk = disks[i]
		cur = i
isi = False
isj = False
i = cur - 1
j = cur + 1
if cur > 0:
	isi = True
if cur < n - 1:
	isj = True
while isi or isj:
	if isi and isj:
		if disks[i] > disks[j]:
			if disks[cur] > disks[i]:
				disks[cur] = disks[i]
				i -= 1
				if i == -1:
					isi = False
			else:
				break
		elif disks[cur] > disks[j]:
			disks[cur] = disks[j]
			j += 1
			if j == n:
				isj = False
		else:
			break
	elif isi:
		if disks[cur] > disks[i]:
			disks[cur] = disks[i]
			i -= 1
			if i == -1:
				isi = False
		else:
			break
	elif disks[cur] > disks[j]:
		disks[cur] = disks[j]
		j += 1
		if j == n:
			isj = False
	else:
		break
else:
	print('Yes')
	exit()
print('No')


import sys
n = int(sys.stdin.readline())
p = list(map(int, sys.stdin.readline().split()))
mi = p.index(n)
t = n
prev = None if mi == 0 else mi - 1
next = None if mi == n - 1 else mi + 1
while t > 1:
	if prev is not None and next is not None:
		if p[prev] + 1 == t:
			mi = prev
			prev = None if mi == 0 else mi - 1
		elif p[next] + 1 == t:
			mi = next
			next = None if mi == n - 1 else mi + 1
		else:
			print('NO')
			exit()
	elif prev is None:
		if p[next] + 1 == t:
			mi = next
			next = None if mi == n - 1 else mi + 1
		else:
			print('NO')
			exit()
	elif p[prev] + 1 == t:
		mi = prev
		prev = None if mi == 0 else mi - 1
	else:
		print('NO')
		exit()
	t -= 1
print('YES')


n = int(input())
a = [int(i) for i in input().split()]
count = 0
maximum = a.index(max(a))
for i in range(0, maximum - 1):
	if a[i] > a[i + 1]:
		count += 1
for j in range(maximum, n - 1):
	if a[j] < a[j + 1]:
		count += 1
if count == 0:
	print('YES')
else:
	print('NO')


Input = lambda : map(int, input().split())
n = int(input())
l = list(Input())
MAX = max(l)
ind = l.index(MAX)
ind1 = ind - 1
ind2 = ind + 1
while ind1 != -1 or ind2 != n:
	if ind1 != -1 and ind2 != n:
		yy = max(l[ind1], l[ind2])
		if yy < MAX:
			MAX = yy
		else:
			print('NO')
			exit()
		if l[ind2] > l[ind1]:
			ind2 += 1
		elif l[ind2] < l[ind1]:
			ind1 -= 1
		else:
			print('NO')
			exit()
	elif ind1 != -1:
		yy = l[ind1]
		if yy < MAX:
			MAX = yy
		else:
			print('NO')
			exit()
		ind1 -= 1
	else:
		yy = l[ind2]
		if yy < MAX:
			MAX = yy
		else:
			print('NO')
			exit()
		ind2 += 1
print('YES')


n = int(input())
p = [int(i) for i in input().split()]
v = [-p[0]]
for i in range(1, n):
	v.append(p[i - 1] - p[i])
flag = False
for i in range(n):
	if v[i] > 0 and flag == False:
		flag = True
	elif v[i] < 0 and flag == True:
		print('NO')
		break
else:
	print('YES')


import sys, operator
n = int(input())
heights = list(map(int, input().split()))

def strictly_increasing(L):
	if not len(L):
		return True
	x = L[0]
	for i in L[1:]:
		if i > x:
			x = i
		else:
			return False
	return True

def strictly_decreasing(L):
	if not len(L):
		return True
	x = L[0]
	for i in L[1:]:
		if i < x:
			x = i
		else:
			return False
	return True
(max_index, value) = max(enumerate(heights), key=operator.itemgetter(1))
if strictly_increasing(heights[0:max_index]) and strictly_decreasing(heights[max_index + 1:]):
	print('YES')
else:
	print('NO')


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


n = int(input())
a = list(map(int, input().split()))
t = a.copy()
t.sort()
t.pop()
ind = a.index(max(a))
i = ind - 1
j = ind + 1
while 1:
	if i == -1 and j == len(a):
		print('YES')
		break
	x = t.pop()
	if i >= 0 and x == a[i]:
		i = i - 1
	elif j < len(a) and x == a[j]:
		j += 1
	else:
		print('NO')
		break


(n, l) = (int(input()), list(map(int, input().split())))
(f, h) = (0, l.index(max(l)))
for i in range(n - 1):
	if i < h:
		if l[i + 1] < l[i]:
			f = 1
			break
	elif l[i + 1] > l[i]:
		f = 1
		break
print(['YES', 'NO'][f == 1])


n = int(input())
s = [int(i) for i in input().split()]
left = s[0:s.index(max(s))]
right = s[s.index(max(s)):]
if sorted(right, reverse=True) == right and sorted(left) == left:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(x) for x in input().split()]
if len(set(l)) < n:
	print('NO')
else:
	mx_idx = l.index(max(l))
	(l_bef, l_aft) = (l[:mx_idx], l[mx_idx + 1:])
	(flag1, flag2) = (0, 0)
	for i in range(len(l_bef)):
		if i > 0 and l_bef[i - 1] > l_bef[i]:
			flag1 += 1
			break
	for i in range(len(l_aft)):
		if i > 0 and l_aft[i - 1] < l_aft[i]:
			flag2 += 1
			break
	if flag1 or flag2:
		print('NO')
	else:
		print('YES')


n = int(input())
a = list(map(int, input().split()))
idx = a.index(max(a))
for i in range(1, n):
	if i > idx:
		if a[i - 1] < a[i]:
			print('NO')
			exit()
	elif a[i - 1] > a[i]:
		print('NO')
		exit()
print('YES')


class Pillar:

	def __init__(self, index, next_index):
		self.disk_count = 1
		self.index = index
		self.prev_index = index - 1 if index > 0 else index
		self.next_index = next_index

	def __repr__(self):
		return f'<i:{self.index} - dc:{self.disk_count}>'

	def is_empty(self):
		return self.disk_count == 0

class Disk:

	def __init__(self, radius, pillar):
		self.radius = radius
		self.pillar = pillar

	def __repr__(self):
		return f'<r:{self.radius} - pi:{self.pillar.index}>'

def can_place(moving_disk, target_disk, empty_pillars_between):
	first_condition = empty_pillars_between or abs(moving_disk.pillar.index - target_disk.pillar.index) == 1
	second_condition = moving_disk.pillar.disk_count == 1
	third_condition = moving_disk.radius < target_disk.radius
	return first_condition and second_condition and third_condition

def move_disk(disk, on_disk):
	disk.pillar.disk_count = 0
	unsorted_pillars[disk.pillar.prev_index].next_index = disk.pillar.next_index
	unsorted_pillars[disk.pillar.next_index].prev_index = disk.pillar.prev_index
	disk.pillar = on_disk.pillar

def are_pillars_between_empty(pillars, start_index, end_index):
	return pillars[start_index].next_index == end_index

def parse_input():
	for (j, value) in enumerate(input().split(' ')):
		unsorted_pillars.append(Pillar(j, j + 1 if j + 1 < pillar_count else j))
		unsorted_disks.append(Disk(int(value), unsorted_pillars[j]))
	return sorted(unsorted_disks, key=lambda d: d.radius, reverse=True)

def can_solve():
	for i in range(0, len(sorted_disks) - 1):
		start_pillar_index = sorted_disks[i].pillar.index if sorted_disks[i].pillar.index < sorted_disks[i + 1].pillar.index else sorted_disks[i + 1].pillar.index
		end_pillar_index = sorted_disks[i].pillar.index if sorted_disks[i].pillar.index > sorted_disks[i + 1].pillar.index else sorted_disks[i + 1].pillar.index
		empty_pillars = are_pillars_between_empty(unsorted_pillars, start_pillar_index, end_pillar_index)
		if not can_place(sorted_disks[i + 1], sorted_disks[i], empty_pillars):
			return False
		else:
			move_disk(sorted_disks[i + 1], sorted_disks[i])
	return True
pillar_count = int(input())
unsorted_pillars = []
unsorted_disks = []
sorted_disks = parse_input()
print('YES' if can_solve() else 'NO')


n = int(input())
ai = list(map(int, input().split()))
num = -1
for i in range(n):
	if ai[i] == n:
		num = i
		break
ans = 1
for i in range(num - 1, -1, -1):
	if ai[i + 1] < ai[i]:
		ans = 0
		break
for i in range(num + 1, n):
	if ai[i - 1] < ai[i]:
		ans = 0
		break
if ans == 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = [int(x) for x in input().split()]
max_elem = s.index(max(s))
ans = True
for i in range(max_elem):
	if s[i] > s[i + 1]:
		ans = False
		break
for i in range(max_elem, n - 1):
	if s[i] < s[i + 1]:
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(x) for x in input().split()]
a = max(l)
p = 0
for i in range(n):
	if l[i] == a:
		p = i
temp = 0
ans = 1
i = 0
while i <= p:
	if l[i] > temp:
		temp = l[i]
		i += 1
		continue
	else:
		ans = 0
		break
while i < n:
	if l[i] < temp:
		temp = l[i]
		i += 1
		continue
	else:
		ans = 0
		break
if ans:
	print('yes')
else:
	print('no')


n = int(input())
data = []
s = input().strip()
data[:] = map(int, s.split())
s = data.copy()
data.sort(reverse=True)
for i in range(len(data) - 1):
	if data[i] == data[i + 1]:
		print('no')
		exit(0)
ind = s.index(data[0])
(leftind, rightind) = (ind - 1, ind + 1)
newd = []
newd.append(s[ind])
while len(newd) != len(s):
	if leftind >= 0 and rightind <= len(s) - 1:
		if s[leftind] >= s[rightind]:
			leftind -= 1
			newd.append(s[leftind + 1])
		else:
			rightind += 1
			newd.append(s[rightind - 1])
	elif leftind < 0:
		rightind += 1
		newd.append(s[rightind - 1])
	else:
		leftind -= 1
		newd.append(s[leftind + 1])
if newd == data:
	print('yes')
else:
	print('no')


n = int(input())
s = list(map(int, input().split()))
k = s.index(max(s))
a = s[:k + 1]
b = s[k:]
if sorted(a) == a and sorted(b, reverse=True) == b:
	print('YES')
else:
	print('NO')


_ = int(input())
pillars = list(map(int, input().split()))
biggest = max(pillars)
bpi = pillars.index(biggest)
biggestSoFar = 0
for i in range(bpi):
	if biggestSoFar > pillars[i]:
		print('NO')
		quit()
	biggestSoFar = pillars[i]
biggestSoFar = 0
for i in reversed(range(bpi + 1, len(pillars))):
	if biggestSoFar > pillars[i]:
		print('NO')
		quit()
	biggestSoFar = pillars[i]
print('YES')


n = int(input())
a = map(int, input().split())
i = p = 0
for x in a:
	i += 1
	(x, p) = (p, x)
	if x > p:
		break
for x in a:
	if x > p:
		break
	p = x
	i += 1
print('YNEOS'[i < n::2])


n = int(input())
l = list(map(int, input().split()))
m = l.index(max(l))
p = 0
for t in range(m, 0, -1):
	if l[t] <= l[t - 1]:
		p = 1
		break
for tt in range(m, len(l) - 1):
	if l[tt] <= l[tt + 1]:
		p = 1
		break
if p == 0:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
up = 1
ind = 0
flag = True
while ind < n - 1:
	if up == 1:
		if l[ind] < l[ind + 1]:
			ind += 1
		else:
			ind += 1
			up = 2
	elif up == 2:
		if l[ind] > l[ind + 1]:
			ind += 1
		else:
			flag = False
			break
if flag:
	print('YES')
else:
	print('NO')


input()
vs = list(map(int, input().split(' ')))
ai = 0
while ai + 1 < len(vs) and vs[ai + 1] > vs[ai]:
	ai += 1
bi = len(vs) - 1
while bi >= 1 and vs[bi - 1] > vs[bi]:
	bi -= 1
if ai == bi:
	print('Yes')
else:
	print('No')


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


n = int(input())
a = list(map(int, input().split()))
index = a.index(n)
start = a[0:index]
end = a[n - 1:index:-1]
if start == sorted(start) and end == sorted(end):
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
mindex = l.index(max(l))
if l[mindex:] == sorted(l[mindex:], reverse=True):
	if l[:mindex] == sorted(l[:mindex]):
		print('yes')
	else:
		print('no')
else:
	print('no')


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


import sys
num = int(sys.stdin.readline())
t = sys.stdin.readline().split(' ')
for i in range(0, num):
	t[i] = int(t[i])
main_pillar = t.index(num)
invariant = 1
for i in range(1, num - 1):
	if t[i] < t[i + 1] and t[i] < t[i - 1]:
		invariant = 0
		break
for i in range(0, main_pillar - 1):
	if t[i] > t[i + 1]:
		invariant = 0
for i in range(main_pillar + 1, num - 1):
	if t[i] < t[i + 1]:
		invariant = 0
if invariant:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
p = 1
r = 1
e = 0
if r == 0:
	print('NO')
else:
	k = max(a)
	t = a.index(k)
	c = max(t, n - t - 1)
	for i in range(c):
		if i < t:
			if a[i] < a[i + 1]:
				pass
			else:
				e = 1
				break
		if i + t < n - 1:
			if a[i + t] > a[i + 1 + t]:
				pass
			else:
				e = 1
				break
	if e == 1:
		print('NO')
	else:
		print('YES')


def readn():
	return int(input())

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

def readnos():
	return map(int, input().split())
n = int(input())
a = readlist()
b = a.copy()
b.sort()
c = a.copy()
c.sort(reverse=True)
if b == a:
	print('YES')
elif c == a:
	print('YES')
else:
	ind = a.index(max(a))
	a1 = a[0:ind]
	a2 = a[ind:n]
	a11 = a1.copy()
	a22 = a2.copy()
	a11.sort()
	a22.sort(reverse=True)
	if a11 == a1 and a22 == a2:
		print('YES')
	else:
		print('NO')


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


from sys import exit
n = int(input())
ls = list(map(int, input().split()))
x = ls.index(max(ls))
for i in range(x):
	if ls[i] >= ls[i + 1]:
		print('NO')
		exit()
for i in range(x, len(ls) - 1):
	if ls[i] <= ls[i + 1]:
		print('NO')
		exit()
print('YES')


input()
L = list(map(int, input().split()))
pos = L.index(max(L))
flag = True
for i in range(pos, 0, -1):
	if L[i] <= L[i - 1]:
		flag = False
		break
for i in range(pos, len(L) - 1):
	if L[i] <= L[i + 1]:
		flag = False
		break
if not flag:
	print('NO')
else:
	print('YES')


n = int(input())
A = list(map(int, input().split()))
i = A.index(max(A))
Bool = True
for x in range(1, i + 1):
	if A[x - 1] > A[x]:
		Bool = False
		break
if Bool == True:
	for x in range(i, n - 1):
		if A[x] < A[x + 1]:
			Bool = False
			break
if Bool == False:
	print('NO')
else:
	print('YES')


n = int(input())
a = [*map(int, input().split())]
i = a.index(n)
print('YNEOS'[a != [*sorted(a[:i]), n, *sorted(a[i + 1:])[::-1]]::2])


def gns():
	return list(map(int, input().split()))
n = int(input())
ns = gns()
mx = max(ns)
(l, r) = (-1, -1)
for i in range(n):
	if ns[i] == mx:
		(l, r) = (i, i)
		break
l -= 1
r += 1
while l >= 0 or r < n:
	if l >= 0 and ns[l] == mx - 1:
		mx -= 1
		l -= 1
		continue
	if r < n and ns[r] == mx - 1:
		mx -= 1
		r += 1
		continue
	print('NO')
	quit()
print('YES')


def main():
	n = int(input())
	f = 0
	ind = 0
	c = 0
	arr = [*map(int, input().split())]
	for i in range(0, n):
		if f < arr[i]:
			f = arr[i]
			ind = i
	for g in range(0, ind):
		if arr[g] < arr[g + 1]:
			c += 1
	for g in range(ind, n - 1):
		if arr[g] > arr[g + 1]:
			c += 1
	if c != n - 1:
		print('NO')
	else:
		print('YES')
main()


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
n = ii()
a = li()
i = a.index(n)
s = sorted
print('YNEOS'[a != s(a[:i]) + s(a[i:])[::-1]::2])


N = int(input())
s = [int(x) for x in input().split()]
pos = []
for i in range(0, N):
	pos.append(i)
dp = sorted(zip(s, pos))
dp = dp[::-1]
flag = 0
p1 = dp[0][1]
p2 = dp[0][1]
for i in range(1, len(dp)):
	if p1 - dp[i][1] == 1:
		p1 -= 1
	elif dp[i][1] - p2 == 1:
		p2 += 1
	else:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
disk = list(map(int, input().split(' ')))
start = disk.index(max(disk))
flag = True
for i in range(start, n - 1):
	if disk[i] <= disk[i + 1]:
		flag = False
		break
if flag:
	for i in range(0, start - 1):
		if disk[i] >= disk[i + 1]:
			flag = False
			break
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
c = 0
pos = 0
while pos < n - 1:
	if l[pos] < l[pos + 1]:
		pos += 1
	else:
		break
while pos < n - 1:
	if l[pos] > l[pos + 1]:
		pos += 1
	else:
		break
if pos == n - 1:
	print('yes')
else:
	print('no')


import sys
cin = lambda : map(int, sys.stdin.readline().split())
n = int(input())
f = [*cin()]
for i in range(1, n - 1):
	if f[i - 1] > f[i] and f[i] < f[i + 1]:
		print('NO')
		exit(0)
print('YES')


n = int(input())
a = [int(x) for x in input().split()]
flag = 0
for i in range(1, len(a) - 1):
	if a[i] < a[i - 1] and a[i] < a[i + 1]:
		flag = 1
		break
	else:
		continue
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
sizes = list(map(int, input().split()))
larg = 0
pos = -1
for i in range(n):
	if sizes[i] > larg:
		larg = sizes[i]
		pos = i
inL = True
decR = True
i = 1
while i <= pos:
	if sizes[i] <= sizes[i - 1]:
		inL = False
	i += 1
i = pos + 1
while i < n:
	if sizes[i] >= sizes[i - 1]:
		decR = False
	i += 1
if inL and decR:
	print('YES')
else:
	print('NO')


n = int(input())
inp = list(map(int, input().split()))
k = inp.index(max(inp))
x = sorted(inp[k:])
x.reverse()
y = sorted(inp[:k])
if x == inp[k:] and y == inp[:k]:
	print('YES')
else:
	print('NO')


def func(n, arr):
	flag = 0
	for i in range(n - 1):
		if arr[i] < arr[i + 1]:
			if flag == 1:
				flag = 2
				break
			continue
		else:
			flag = 1
	if flag == 2:
		print('no')
	else:
		print('yes')
n = int(input())
arr = [int(i) for i in input().split()]
func(n, arr)


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
j = a.index(n)
for i in range(j):
	if a[i] > a[i + 1]:
		print('NO')
		exit()
for i in range(j, n - 1):
	if a[i] < a[i + 1]:
		print('NO')
		exit()
print('YES')


n = int(input())
disk = list(map(int, input().split()))
s = max(disk)
index = disk.index(s)
a = disk[:index]
b = disk[index + 1:]
c = a.copy()
d = b.copy()
c.sort()
d.sort(reverse=True)
if c == a:
	if d == b:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


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


import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
i = a.index(max(a))
v = True
for j in range(0, i):
	if a[j] > a[j + 1]:
		v = False
for j in range(i, n - 1):
	if a[j] < a[j + 1]:
		v = False
if v == True:
	print('YES')
else:
	print('NO')


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


from sys import exit
n = int(input())
a = [int(x) for x in input().split()]
ind = a.index(max(a))
m = max(a)
l = ind - 1
r = ind + 1
while m > 1:
	if l > -1 and a[l] == m - 1:
		m -= 1
		l -= 1
	elif r < n and a[r] == m - 1:
		m -= 1
		r += 1
	else:
		print('NO')
		exit()
print('YES')


p = int(input())
a = list(map(int, input().split()))
mx = -1
for i in range(p):
	if a[i] > mx:
		ind = i
		mx = a[i]
a1 = a[:ind]
a2 = a[ind + 1:]
print('YES' if a1 == sorted(a1) and a2 == sorted(a2, reverse=True) else 'NO')


n = int(input())
a = [int(x) for x in input().split()]
flag = 0
for i in range(1, n - 1):
	if (a[i] > a[i - 1] and a[i] > a[i + 1] or (a[i] < a[i - 1] and a[i] < a[i + 1])) and a[i] != max(a):
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append((a[i], i))
b.sort(reverse=True)
a = set()
a.add(b[0][1])
flag = True
for i in b[1:]:
	if i[1] + 1 in a or i[1] - 1 in a:
		a.add(i[1])
	else:
		flag = False
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
arr = list(map(int, input().split()))
max_val = temp = max(arr)
max_idx = i = arr.index(max_val)
tr = True
while tr and i >= 0:
	if arr[i] <= temp:
		temp = arr[i]
		i -= 1
	else:
		tr = False
if tr == False:
	print('NO')
else:
	i = max_idx
	temp = max_val
	while tr and i <= n - 1:
		if arr[i] <= temp:
			temp = arr[i]
			i += 1
		else:
			tr = False
	print('YES' if tr == True else 'NO')


n = int(input())
a = list(map(int, input().split()))
if n <= 2:
	print('YES')
else:
	mx = max(a)
	t = a.index(mx)
	l = 0
	r = 0
	if t > 0:
		for i in range(t - 1, -1, -1):
			if a[i] > mx:
				l = 1
				break
			else:
				mx = a[i]
	if t < n - 1:
		mx = max(a)
		for i in range(t + 1, n):
			if a[i] > mx:
				r = 1
				break
			else:
				mx = a[i]
	if l == 0 and r == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
A = list(map(int, input().split()))
maks = A[0]
maksid = 0
for i in range(1, n):
	if A[i] > maks:
		maks = A[i]
		maksid = i
for i in range(1, maksid):
	if A[i - 1] > A[i]:
		print('NO')
		exit()
for i in range(maksid + 1, n):
	if A[i - 1] < A[i]:
		print('NO')
		exit()
print('YES')


import math
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
M = 10 ** 9 + 7

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def Freq(l):
	f = {}
	for i in l:
		if i in f:
			f[i] += 1
		else:
			f[i] = 1
	return f
inp = lambda : int(stdin.readline())
sip = lambda : stdin.readline()
mulip = lambda : map(int, stdin.readline().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
n = inp()
A = lst()
B = sorted(A)
if B == A or A == B[::-1]:
	print('YES')
else:
	cnt = 0
	if len(A) == 1 or len(A) == 2:
		print('YES')
	elif len(A) == 3:
		if max(A) == A[1] and A[0] != A[2]:
			print('YES')
		else:
			print('NO')
	else:
		mx = max(A)
		imx = A.index(mx)
		for i in range(imx, len(A) - 1):
			if A[i] > A[i + 1]:
				cnt += 1
		for i in range(1, imx + 1):
			if A[i - 1] < A[i]:
				cnt += 1
		if len(set(B)) == len(A) and cnt == len(A) - 1:
			print('YES')
		else:
			print('NO')


n = int(input())
aa = list(map(int, input().split()))
mx = max(aa)
if len(list(filter(lambda x: x == mx, aa))) > 1:
	print('NO')
imx = aa.index(mx)
up = aa[:imx]
down = aa[imx:]
if len(up) >= 2:
	for i in range(1, len(up)):
		if up[i - 1] >= up[i]:
			print('NO')
			exit(0)
if len(down) >= 2:
	for i in range(1, len(down)):
		if down[i - 1] <= down[i]:
			print('NO')
			exit(0)
print('YES')


n = int(input())
l = list(map(int, input().split()))
a = max(l)
z = l.index(a)
l1 = l[:z]
l2 = l[z:]
l2.reverse()
if l1 == sorted(l1) and l2 == sorted(l2):
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
x = arr.index(n)
if sorted(arr[:x]) == arr[:x] and sorted(arr[x + 1:])[::-1] == arr[x + 1:]:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
max_idx = 0
for i in range(1, len(arr)):
	if arr[max_idx] < arr[i]:
		max_idx = i
i = max_idx - 1
j = max_idx + 1
cur = arr[max_idx]
threshold = -1000000000.0
while i >= 0 or j <= n:
	left = threshold if i < 0 else arr[i]
	right = threshold if j >= n else arr[j]
	smallest = max(left, right)
	if smallest == threshold:
		print('YES')
		break
	elif smallest == right and smallest < cur:
		cur = smallest
		j += 1
	elif smallest == left and smallest < cur:
		cur = smallest
		i -= 1
	else:
		print('NO')
		break


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

def possible():
	if maxi == n - 1:
		return arr == sorted(arr)
	if maxi == 0:
		return arr == list(reversed(sorted(arr)))
	return arr[:maxi + 1] == sorted(arr[:maxi + 1]) and arr[maxi:] == list(reversed(sorted(arr[maxi:])))
if possible():
	print('YES')
else:
	print('NO')


def fun(a, b):
	state = True
	a = int(a)
	bl = list(map(int, b.split()))
	max_ind = bl.index(max(bl))
	sp1 = bl[:max_ind + 1]
	sp2 = bl[max_ind:]
	for i in range(len(sp1) - 1):
		if sp1[i] > sp1[i + 1]:
			state = False
	for i in range(1, len(sp2)):
		if sp2[i - 1] < sp2[i]:
			state = False
	if state == True:
		return 'Yes'
	else:
		return 'No'
a = input()
b = input()
print(fun(a, b))


n = int(input())
l = []
l = input().split()
s = set(l)
if len(s) != n:
	print('NO')
	exit(0)
for i in range(1, n - 1):
	if int(l[i - 1]) > int(l[i]) and int(l[i]) < int(l[i + 1]):
		print('NO')
		exit(0)
print('YES')


import collections
n = int(input())
a = list(map(int, input().split()))
a = {i: j for (i, j) in enumerate(a)}
(m, idx) = (0, 0)
ans = 'YES'
for i in range(n):
	if a[i] > m:
		m = a[i]
		idx = i
for i in range(1, idx):
	if a[i] < a[i - 1]:
		ans = 'NO'
		break
for i in range(idx + 1, n):
	if a[i] > a[i - 1]:
		ans = 'NO'
		break
print(ans)


from collections import Counter as cr

def fn(r):
	if len(r) == 1 or len(r) == 0:
		return 1
	else:
		i = 1
		while i < len(r) and r[i] > r[i - 1]:
			i += 1
		if i == len(r):
			return 1
		else:
			return 0
n = int(input())
l = [int(e) for e in input().split()]
m = cr(l)
s = set(m.values())
if 1 in s and len(s) > 1 or (1 not in s and len(s) > 0):
	print('NO')
else:
	x = l.index(max(l))
	if fn(l[:x]) == 1 and fn(l[x + 1:][::-1]) == 1:
		print('YES')
	else:
		print('NO')


def printer(arr, m):
	prev = arr[m]
	for i in range(m, len(arr)):
		if prev < arr[i]:
			return 'NO'
		else:
			prev = arr[i]
	prev = arr[m]
	for i in range(m, -1, -1):
		if prev < arr[i]:
			return 'NO'
		else:
			prev = arr[i]
	return 'YES'
pillars = int(input())
arr = input().split(' ')
for i in range(len(arr)):
	arr[i] = int(arr[i])
m = max(arr)
index = arr.index(m)
print(printer(arr, index))


n = int(input())
a = [int(i) for i in input().split()]
c = a.index(max(a))
d = a[0:c]
e = a[c:]
flag = 0
if len(d) <= 1:
	pass
else:
	for i in range(0, len(d) - 1):
		if d[i + 1] > d[i]:
			pass
		else:
			flag = 1
			break
if len(e) <= 1:
	pass
else:
	for i in range(0, len(e) - 1):
		if e[i + 1] < e[i]:
			pass
		else:
			flag = 1
			break
if flag == 1:
	print('NO')
else:
	print('YES')


(n, a) = (int(input()), list(map(int, input().split())))
m = a.index(max(a))
if a[:m] != list(sorted(a[:m])) or a[m + 1:] != list(sorted(a[m + 1:], reverse=True)):
	print('NO')
else:
	print('YES')


def ladder():
	pillars = int(input())
	radii = []
	maxVal = 0
	idxMax = 0
	count = 0
	result1 = ''
	result2 = ''
	result3 = ''
	radii = input().split()
	for i in range(pillars):
		radii[i] = int(radii[i])
	idxMax = radii.index(max(radii))
	maxVal = radii[idxMax]
	if radii[:idxMax] == sorted(radii[:idxMax]) and radii[idxMax:] == sorted(radii[idxMax:], reverse=True):
		result1 = 'YES'
	else:
		result3 = 'NO'
	if result3 != 'NO':
		print(result1)
	else:
		print(result3)
ladder()


n = int(input())
L = [int(x) for x in input().split()]
mx = max(L)
ok = True
i = 0
if L[0] == mx:
	pass
else:
	i = 1
	while L[i] != mx:
		if L[i] < L[i - 1]:
			ok = False
		i += 1
i += 1
while i < n:
	if L[i] > L[i - 1]:
		ok = False
	i += 1
if ok == False:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
for i in range(1, n - 1):
	if a[i - 1] > a[i] and a[i + 1] > a[i]:
		print('no')
		exit(0)
print('yes')


def f(l):
	for i in range(len(l) - 1):
		if l[i] > l[i + 1]:
			break
	if sorted(l[i + 1:], reverse=True) == l[i + 1:]:
		return 0
	return 1
M = 10 ** 9 + 7
R = lambda : map(int, input().split())
n = int(input())
L = list(R())
if len(set(L)) != n:
	print('NO')
else:
	print('YNEOS'[f(L)::2])


from sys import stdin, stdout
from collections import Counter
import math

def rsingle_int():
	return int(stdin.readline().rstrip())

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

def r_str():
	return stdin.readline().rstrip()

def rsingle_char():
	return stdin.read(1)

def main():
	n = rsingle_int()
	a = rmult_int()
	max = 0
	for el in a:
		if el > max:
			max = el
	possible = True
	increasing = True
	st = 0
	for el in a:
		if el == max:
			increasing = False
		elif increasing:
			if el <= st:
				possible = False
				break
		elif el >= st:
			possible = False
			break
		st = el
	if possible:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
a = list(map(int, input().split(' ')))
mx = a.index(n)
left = a[:mx]
right = a[mx + 1:]
if left == sorted(left) and right == sorted(right)[::-1]:
	print('YES')
else:
	print('NO')


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


n = int(input())
a = list(map(int, input().split()))
p = -1
for i in range(n):
	if a[i] == n:
		p = i
		break
valid = True
for i in range(1, p + 1):
	if a[i] < a[i - 1]:
		valid = False
for i in range(p, n - 1):
	if a[i] < a[i + 1]:
		valid = False
if valid:
	print('yes')
else:
	print('no')


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


n = int(input())
a = list(map(int, input().split()))
l = max(a)
for i in range(0, n):
	if a[i] == l:
		g = i
		break
p1 = a[0:g]
p2 = a[g + 1:n]
p1.sort()
p2.sort()
p2.reverse()
if p1 == a[0:g] and p2 == a[g + 1:n]:
	print('yes')
else:
	print('no')


n = int(input())
l = list(map(int, input().split()))
m = max(l)
ind = l.index(m)
b = l[:ind]
c = l[ind:]
if sorted(b) == b and sorted(c, reverse=True) == c:
	print('yes')
else:
	print('no')


n = int(input())
a = list(map(int, input().split()))
current = n
left = right = a.index(current)
answer = True
while left >= 0 and right <= n - 1 and (current > 1):
	current -= 1
	if left - 1 >= 0 and a[left - 1] == current:
		left -= 1
		continue
	elif right + 1 <= n - 1 and a[right + 1] == current:
		right += 1
		continue
	else:
		answer = False
		break
print('YES' if answer else 'NO')


n = input()
l = list(map(int, input().split()))
pos = l.index(max(l))
res = True
for i in range(0, pos):
	res = res and l[i] < l[i + 1]
for i in range(pos, len(l) - 1):
	res = res and l[i] > l[i + 1]
if res:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split(' ')]
(m, mi) = (-1, -1)
for (i, num) in enumerate(a):
	if num > m:
		m = num
		mi = i
last = m
e = False
for i in range(mi - 1, -1, -1):
	if a[i] >= last:
		print('NO')
		e = True
		break
	last = a[i]
if not e:
	last = m
	for i in range(mi + 1, len(a)):
		if a[i] >= last:
			print('NO')
			e = True
			break
		last = a[i]
	if not e:
		print('YES')


n = int(input())
a = [int(i) for i in input().split()]
s = max(a)
s1 = a.index(s)
a1 = a[0:s1]
a2 = a[s1 + 1:]
a3 = sorted(a1)
a4 = sorted(a2)
a4.reverse()
if a1 == a3 and a2 == a4:
	print('yes')
else:
	print('no')


n = int(input())
pos = 0
mx = 0
c = list(map(int, input().split()))
for i in range(n):
	if c[i] > mx:
		mx = c[i]
		pos = i
ok = 0
for i in range(1, n):
	if i <= pos:
		if c[i] < c[i - 1]:
			ok = 1
	elif c[i] > c[i - 1]:
		ok = 1
if ok:
	print('NO')
else:
	print('YES')


import sys
n = int(input())
list1 = [*map(int, input().split())]
count = 0
for i in range(1, n - 1):
	if list1[i - 1] > list1[i] and list1[i] < list1[i + 1]:
		count = count + 1
if count > 0:
	print('NO')
else:
	print('YES')


from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
i = j = a.index(n)
t = n - 1
if j == n:
	i -= 1
elif i == 0:
	j += 1
else:
	i -= 1
	j += 1
while i > -1 or j < n:
	if i > -1 and a[i] == t:
		i -= 1
		t -= 1
	elif j < n and a[j] == t:
		j += 1
		t -= 1
	else:
		break
if t == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
bsb = 0
for i in range(1, n - 1):
	if a[i] < a[i + 1] and a[i - 1] > a[i]:
		bsb += 1
if bsb >= 1:
	print('NO')
else:
	print('YES')


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

def sai():
	i = 1
	indexma = a.index(ma)
	while i < indexma:
		if a[i] == ma:
			break
		if a[i] < a[i - 1]:
			return 'NO'
		i += 1
	while i < n - 1:
		if a[i] < a[i + 1]:
			return 'NO'
		i += 1
	return 'YES'
print(sai())


n = int(input())
arrs = [int(x) for x in input().split()]
i = 0
while i < n - 1 and arrs[i] < arrs[i + 1]:
	i += 1
while i < n - 1 and arrs[i] > arrs[i + 1]:
	i += 1
print(['NO', 'YES'][i == n - 1])


for t in range(1):
	n = int(input())
	arr = list(map(int, input().split()))
	pos = arr.index(n)
	if sorted(arr[:pos]) == arr[:pos] and sorted(arr[pos:], reverse=True) == arr[pos:]:
		print('YES')
	else:
		print('NO')


def pro(arr):
	ind = 0
	maxi = 0
	for i in range(len(arr)):
		if arr[i] > maxi:
			maxi = arr[i]
			ind = i
	for i in range(ind - 1):
		if arr[i] > arr[i + 1]:
			print('NO')
			return
	for i in range(ind + 1, len(arr) - 1):
		if arr[i] < arr[i + 1]:
			print('NO')
			return
	print('YES')
n = int(input())
arr = list(map(int, input().split()))
pro(arr)


n = int(input())
r_val_ith_pillar = list(map(int, input().split()))
m_value = -1
m_index = -1
for i in range(n):
	if r_val_ith_pillar[i] > m_value:
		m_value = r_val_ith_pillar[i]
		m_index = i + 1
point = 0
for i in range(m_index - 1):
	if r_val_ith_pillar[i] > r_val_ith_pillar[i + 1]:
		point = 1
for i in range(m_index, n):
	if r_val_ith_pillar[i - 1] < r_val_ith_pillar[i]:
		point = 1
if point == 1:
	print('No')
else:
	print('Yes')


def check(arr, n):
	flag = 0
	for i in range(n - 1):
		if arr[i] < arr[i + 1]:
			if flag == -1:
				print('NO')
				return
		else:
			flag = -1
	print('YES')
n = int(input())
arr = list(map(int, input().split()))
check(arr, n)


n = int(input())
a = [int(x) for x in input().split()]
m = a.index(n)
for x in range(1, m):
	if a[x] < a[x - 1]:
		print('NO')
		exit()
for x in range(m + 1, n):
	if a[x] > a[x - 1]:
		print('NO')
		exit()
print('YES')


n = int(input())
arr = [int(i) for i in input().split()]
flag = True
t = 0
for i in range(n - 1):
	if arr[i] < arr[i + 1] and t == 0:
		continue
	elif arr[i] > arr[i + 1] and t == 0:
		t = 1
	elif arr[i] > arr[i + 1] and t == 1:
		continue
	else:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
m = l.index(max(l))
g = list()
g1 = l[0:m].copy()
g2 = l[m + 1:].copy()
g1.sort()
g2.sort(reverse=True)
if g1 == l[0:m] and g2 == l[m + 1:]:
	print('YES')
else:
	print('NO')


N = int(input())
A = input().split()
A = list(map(int, A))
max_ = 0
max_index = 0
for i in range(N):
	if A[i] > max_:
		max_ = A[i]
		max_index = i
error = False
for j in range(1, max_index):
	if A[j] < A[j - 1]:
		error = True
		break
if not error:
	for j in range(max_index + 1, N):
		if A[j] > A[j - 1]:
			error = True
			break
if error:
	print('No')
else:
	print('Yes')


column_count = int(input())
columns = input().split()
for i in range(len(columns)):
	columns[i] = int(columns[i])
max_index = columns.index(max(columns))
risingA = False
for i in range(max_index, len(columns) - 1):
	if columns[i] < columns[i + 1]:
		risingA = True
risingB = False
for i in range(max_index, 0, -1):
	if columns[i - 1] > columns[i]:
		risingB = True
if not risingA and (not risingB):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
if len(set(a)) != n:
	print('NO')
	exit(0)
c = 0
for i in range(n - 1):
	if a[i] > a[i + 1]:
		c = i + 1
		break
if c == 0:
	print('YES')
	exit(0)
for i in range(c, n - 1):
	if a[i] < a[i + 1]:
		print('NO')
		exit(0)
print('YES')


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


n = int(input())
lis = [int(x) for x in input().split()]
maxIndex = lis.index(n)
res = True
for i in range(1, maxIndex):
	if lis[i] < lis[i - 1]:
		res = False
		break
for i in range(maxIndex, n - 1):
	if lis[i] < lis[i + 1]:
		res = False
		break
print('YES' if res else 'NO')


import sys
input = sys.stdin.readline
from math import ceil, floor

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
asc = []
dsc = []
f = 0
for i in a:
	if f == 0:
		asc.append(i)
		if i == n:
			f = 1
	else:
		dsc.append(i)
if asc == sorted(asc) and dsc == sorted(dsc, reverse=1):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
j = a.index(max(a))
j += 1
(i, k) = (j - 1, j + 1)
a.insert(0, 0)
a.append(0)
while i > 0 or k < n + 1:
	if a[i] > a[k] and a[i] < a[j]:
		a[j] = a[i]
		i -= 1
	elif a[i] < a[k] and a[k] < a[j]:
		a[j] = a[k]
		k += 1
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
pillars_str = input().split()
pillars = [int(pillar) for pillar in pillars_str]
possible = True
increasing = True
prev_pillar = 0
for pillar in pillars:
	if increasing:
		if prev_pillar < pillar:
			prev_pillar = pillar
		else:
			prev_pillar = pillar
			increasing = False
	elif prev_pillar > pillar:
		prev_pillar = pillar
	else:
		possible = False
		break
if possible:
	print('YES')
else:
	print('NO')


n = int(input())
arr = [int(s) for s in input().split()]
rec = max(arr)
l = r = 0
for i in range(n):
	if arr[i] == rec:
		l = r = i
find = n - 1
ans = 1
while find != 0:
	if l != 0 and arr[l - 1] == find:
		l -= 1
		find -= 1
	elif r != n - 1 and arr[r + 1] == find:
		r += 1
		find -= 1
	else:
		ans = 0
		break
print('YES' * ans + 'NO' * (1 - ans))


h = int(input())
list1 = list(map(int, input().split()))
for i in range(1, h - 1):
	if list1[i] < list1[i - 1] and list1[i + 1] > list1[i]:
		print('NO')
		exit(0)
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
index = 0
mx = -1
f = True
for i in range(n):
	if mx < l[i]:
		index = i
		mx = l[i]
for i in range(index, n - 1):
	if l[i] < l[i + 1]:
		f = False
for i in range(index, 0, -1):
	if l[i] < l[i - 1]:
		f = False
if not f:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
l = a.index(max(a))
if l > 0 and a[l - 1] == n - 1:
	r = l
	l = r - 1
elif l < n - 1 and a[l + 1] == n - 1:
	r = l + 1
else:
	print('no')
	exit()
ctr = 2
while ctr < n:
	if l > 0 and a[l - 1] == n - ctr:
		ctr += 1
		l -= 1
	elif r < n - 1 and a[r + 1] == n - ctr:
		ctr += 1
		r += 1
	else:
		break
else:
	print('yes')
	exit()
print('no')


n = int(input())
a = list(map(int, input().split()))
flag = 1
ind = a.index(max(a))
for i in range(1, len(a) - 1):
	if a[i] < a[i + 1] and a[i] < a[i - 1]:
		print('NO')
		flag = 0
		break
if flag == 1:
	asc = a[:ind]
	temp1 = sorted(asc)
	if asc == temp1:
		dsc = a[ind + 1:]
		temp2 = sorted(dsc, reverse=True)
		if dsc == temp2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
L = list(map(int, input().split()))
s = set(L)
if len(s) != len(L):
	print('NO')
else:
	ind = L.index(max(L))
	nl = L[0:ind + 1]
	rnl = L[ind:]
	snl = list(set(nl))
	srnl = list(set(rnl))
	snl.sort()
	srnl.sort(reverse=True)
	if nl == snl and rnl == srnl:
		print('YES')
	else:
		print('NO')


n = int(input())
arr = [int(x) for x in input().split()]
x = arr.index(max(arr))
cur = max(arr)
l = x - 1
r = x + 1
ok = 1
for i in range(n - 1):
	if l < 0:
		ok *= arr[r] < cur
		cur = arr[r]
		r += 1
	elif r >= n:
		ok *= arr[l] < cur
		cur = arr[l]
		l -= 1
	elif arr[l] > arr[r]:
		ok *= arr[l] < cur
		cur = arr[l]
		l -= 1
	else:
		ok *= arr[r] < cur
		cur = arr[r]
		r += 1
print('YES' if ok else 'NO')


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


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


n = int(input())
temp = list(map(int, input().strip().split()))
data = []
for i in range(0, n):
	data.append([temp[i], i])
data = sorted(data, reverse=True)
temp_stack = data[0][0]
idx = data[0][1]
flag = False
for j in range(1, n):
	curr_idx = data[j][1]
	diff_idx = abs(idx - curr_idx)
	if diff_idx > 1:
		c = -1
		if idx > curr_idx:
			c = 1
		curr_idx += c
		if temp[curr_idx] < data[j][0]:
			flag = True
			break
if flag == True:
	print('NO')
else:
	print('Yes')


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
a = [0] + I() + [0]
k = a.index(n)
x = k
y = k
for i in range(n - 1, 0, -1):
	if a[x - 1] == i:
		x -= 1
	elif a[x + 1] == i:
		x += 1
	elif a[y - 1] == i:
		y -= 1
	elif a[y + 1] == i:
		y += 1
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
li = list(map(int, input().split()))
x = li.index(max(li))
if li[:x] == sorted(li[:x]) and li[x:] == sorted(li[x:])[::-1]:
	print('YES')
else:
	print('NO')


n = int(input())
arr = [int(x) for x in input().split(' ')]
bada = max(arr)
pos = arr.index(bada)
stack1 = arr[:pos]
stack2 = arr[pos + 1:]
stack2.reverse()
curr = bada - 1
flag = 0
while True:
	if len(stack1) and stack1[-1] == curr:
		stack1.pop()
		curr -= 1
	elif len(stack2) and stack2[-1] == curr:
		stack2.pop()
		curr -= 1
	else:
		if curr == 0:
			print('YES')
		else:
			print('NO')
		break


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.buffer.readline
	N = int(input())
	A = list(map(int, input().split()))
	ii = -1
	for i in range(N):
		if A[i] == N:
			ii = i
			break
	ok = 1
	for i in range(ii):
		if A[i + 1] < A[i]:
			ok = 0
			break
	for i in range(ii + 1, N):
		if A[i] > A[i - 1]:
			ok = 0
			break
	if ok:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
a = list(map(int, input().split()))
peak_reached = False
prev = a[0]
for i in range(1, n):
	if not peak_reached:
		if a[i] < prev:
			peak_reached = True
	elif a[i] > prev:
		print('NO')
		exit()
	prev = a[i]
print('YES')


n = int(input())
arr = list(map(int, input().split(' ')))
k = arr.index(max(arr))
k += 1
ok = True
for i in range(1, k - 1):
	ok &= arr[i - 1] < arr[i]
for i in range(k, n - 1):
	ok &= arr[i + 1] < arr[i]
if ok:
	print('YES')
else:
	print('NO')


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


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		l = 0
		r = n - 1
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				l = i + 1
			else:
				break
		for i in range(n - 2, -1, -1):
			if a[i] > a[i + 1]:
				r = i
			else:
				break
		rr.append(YES(l == r))
	return JA(rr, '\n')
print(main())


def check_sorted(array, from_less=True):
	for i in range(len(array) - 1):
		if from_less:
			if array[i] > array[i + 1]:
				return False
		elif array[i] < array[i + 1]:
			return False
	return True
N = int(input())
arr = list(map(int, input().split()))
ind = arr.index(max(arr))
left_sorted = check_sorted(arr[:ind])
right_sorted = check_sorted(arr[ind:], from_less=False)
if left_sorted and right_sorted:
	print('YES')
else:
	print('NO')


n = int(input())
lis = list(map(int, input().split()))
acen = sorted(lis)
decen = sorted(lis, reverse=True)
if lis == acen or lis == decen:
	print('YES')
else:
	k = 0
	for i in range(2, n):
		if lis[i - 2] > lis[i - 1] < lis[i]:
			k = 1
			break
	if k == 0:
		print('YES')
	else:
		print('NO')


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	ind = 0
	lst.append(-1)
	for i in range(n):
		if lst[i] >= lst[i + 1]:
			ind = i
			break
	for i in range(ind, n - 1):
		if lst[i] <= lst[i + 1]:
			return 'NO'
	return 'YES'
n = int(input())
lst = list(map(int, input().split()))
print(solve(n, lst))


import sys
n = int(input())
L = [int(x) for x in input().split()]
M = max(L)
i = L.index(M)
for j in range(i):
	if L[j] > L[j + 1]:
		print('NO')
		sys.exit(0)
for j in range(i, n - 1):
	if L[j] < L[j + 1]:
		print('NO')
		sys.exit(0)
print('YES')


n = int(input())
a = [int(i) for i in input().split()]
fail = 0
num_max = max(a)
index_max = a.index(num_max)
for i in range(index_max):
	if a[i] > a[i + 1]:
		fail = 1
		break
for i in range(index_max, n - 1):
	if a[i] < a[i + 1]:
		fail = 1
		break
if not fail:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(i) for i in input().split()]
k = a.index(max(a))
s = 0
for i in range(0, k):
	if a[i] < a[i + 1]:
		s += 1
for j in range(k, n - 1):
	if a[j] > a[j + 1]:
		s += 1
if s == n - 1:
	print('YES')
else:
	print('NO')


x = int(input())
a = list(map(int, input().split()))
b = max(a)
c = a.index(b)
d = c - 1
if c < x:
	c += 1
f = 0
while c < x:
	if a[c] > a[c - 1]:
		f = 1
		break
	c += 1
while d >= 0:
	if a[d] > a[d + 1]:
		f = 1
		break
	d -= 1
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = [*map(int, input().split())]
m = max(a)
i = a.index(m)
(t1, t2) = ([], [])
for j in range(i):
	t1.append(m - a[j])
for j in range(i, n):
	t2.append(m - a[j])
if t1 == sorted(t1, reverse=True) and t2 == sorted(t2):
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
k = 0
for i in range(n):
	if a[i] > a[k]:
		k = i
ch = 1
for i in range(k - 1):
	if a[i + 1] <= a[i]:
		ch = 0
for i in range(k, n - 1):
	if a[i + 1] >= a[i]:
		ch = 0
if ch == 0:
	print('NO')
else:
	print('YES')


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


n = int(input())
a = list(map(int, input().split()))
m = max(a)
ind = a.index(max(a))
i = ind - 1
j = ind + 1
while i >= 0 and j < n:
	if a[i] == m - 1:
		i -= 1
		m -= 1
	elif a[j] == m - 1:
		j += 1
		m -= 1
	else:
		exit(print('NO'))
while i >= 0:
	if a[i] == m - 1:
		i -= 1
		m -= 1
	else:
		exit(print('NO'))
while j < n:
	if a[j] == m - 1:
		j += 1
		m -= 1
	else:
		exit(print('NO'))
print('YES')


from sys import stdin
read = stdin.readline
n = int(read())
poss = asc = True
prev = 0
for i in map(int, read().split()):
	if i > prev:
		if not asc:
			poss = False
			break
	elif i < prev:
		asc = False
	else:
		poss = False
		break
	prev = i
if poss:
	print('Yes')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
idx = arr.index(max(arr))
flag1 = True
flag2 = True
for i in range(0, idx):
	if arr[i] > arr[i + 1]:
		flag1 = False
for i in range(idx, n - 1):
	if arr[i] < arr[i + 1]:
		flag2 = False
if flag1 == True and flag2 == True:
	print('YES')
else:
	print('NO')


k = 0
b = 0
n = int(input())
a = input().split()
max = int(a[0])
for i in range(n):
	if max < int(a[i]):
		max = int(a[i])
		b = i
i = 0
while i >= 0 and i < b - 1:
	if int(a[i]) < int(a[i + 1]):
		k = 0
	else:
		k = 1
		break
	i = i + 1
i = b + 1
if k == 0:
	while i > b and i <= n - 2:
		if int(a[i]) > int(a[i + 1]):
			k = 0
		else:
			k = 1
			break
		i = i + 1
if k == 1:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
amax = max(a)
iamax = a.index(amax)
(aa, bb) = (a[:iamax], a[iamax:])
(sa, sb) = (sorted(aa), sorted(bb, reverse=True))
if aa == sa and bb == sb:
	print('YES')
else:
	print('NO')


tc = int(input())
a = [int(i) for i in input().split()]
t = max(a)
p = a.index(t)
a_r = a[p:]
a_r.sort(reverse=True)
if p == 0:
	final = a_r
else:
	a_b = a[:p]
	a_b.sort()
	final = a_b + a_r
flag = 0
for i in range(len(a)):
	if a[i] == final[i]:
		continue
	else:
		flag = 1
if flag:
	print('No')
else:
	print('Yes')


N = int(input())
vals = [int(x) for x in input().split(' ') if len(x) > 0]
k = vals.index(max(vals))
if k == 0:
	bef = []
else:
	bef = vals[0:k]
if k == len(vals) - 1:
	aft = []
else:
	aft = vals[k + 1:]
if sorted(bef) == bef and sorted(aft, reverse=True) == aft:
	print('YES')
else:
	print('NO')


from sys import exit
input()
a = list(map(int, input().split()))
c = 0
if len(a) == 3:
	if a[0] < a[1] < a[2] or a[0] > a[1] > a[2]:
		print('YES')
	else:
		print('NO')
else:
	for i in range(1, len(a) - 1):
		if a[i - 1] > a[i] and a[i] < a[i + 1]:
			c = 4
			break
		if a[i - 1] < a[i] and a[i] > a[i + 1]:
			c += 1
	print('YES' if c < 2 else 'NO')


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
if len(set(b)) != n:
	print('NO')
else:
	p = max(b)
	q = b.index(p)
	t = 0
	j = q - 1
	while j >= 1:
		if b[j] <= b[j - 1]:
			t = 1
			break
		j += -1
	for j in range(q + 1, n - 1):
		if b[j] <= b[j + 1]:
			t = 1
			break
	if t == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
lst = list(map(int, input().split()))
m = lst.index(max(lst))
flag = True
i = 0
while i < m:
	if lst[i] > lst[i + 1]:
		flag = False
		break
	i += 1
j = m
while j < n - 1:
	if lst[j] < lst[j + 1]:
		flag = False
		break
	j += 1
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
index = a.index(max(a))
left = a[:index]
right = a[index:]
l = left.copy()
left.sort()
right.reverse()
r = right.copy()
right.sort()
if r == right and left == l:
	print('YES')
else:
	print('NO')


n = int(input())
y = list(map(int, input().split()))
ind = y.index(max(y))
j = 1
f = 0
while j < ind:
	if y[j] < y[j - 1]:
		f = 1
		break
	j += 1
if f != 1:
	j = ind + 1
	f = 0
	while j < n:
		if y[j] > y[j - 1]:
			f = 2
			break
		j += 1
	if f == 2:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
ans = 1
ind = a.index(max(a))
for i in range(ind):
	ans *= a[i] < a[i + 1]
for i in range(ind, n - 1):
	ans *= a[i] > a[i + 1]
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
flag = 0
decreasing = 0
radius = list(map(int, input().split()))
status = []
for i in range(n - 1):
	if radius[i] < radius[i + 1]:
		status.append('inc')
	else:
		status.append('dec')
if radius[i + 1] > radius[i]:
	status.append('inc')
else:
	status.append('dec')
for i in range(n - 1):
	if status[i] == 'inc' and status[i + 1] == 'dec':
		decreasing += 1
		if decreasing > 1:
			flag = 1
			break
	elif status[i] == 'dec' and status[i + 1] == 'inc':
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


def ka(x, ind):
	lef = x[:ind][::-1]
	rig = x[ind + 1:]
	k = x[ind]
	i = j = 0
	while i < len(lef) and j < len(rig):
		if lef[i] > rig[j]:
			if lef[i] < k:
				k = lef[i]
				i += 1
			else:
				return 0
		elif lef[i] < rig[j]:
			if rig[j] < k:
				k = rig[j]
				j += 1
			else:
				return 0
		else:
			return 0
	if i == len(lef):
		if rig[j:] == sorted(rig[j:])[::-1]:
			return 1
	if j == len(rig):
		if lef[i:] == sorted(lef[i:])[::-1]:
			return 1
	return 0
n = int(input())
l = list(map(int, input().split()))
if ka(l, l.index(max(l))):
	print('Yes')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
flag = 0
if a[0] < a[1]:
	ascend = True
else:
	ascend = False
	flag = 1
ans = 'YES'
for i in range(n - 1):
	if ascend:
		if a[i] < a[i + 1]:
			continue
		else:
			if flag == 1:
				ans = 'NO'
				break
			flag = 1
			ascend = False
	elif a[i] > a[i + 1]:
		continue
	else:
		if flag == 1:
			ans = 'NO'
			break
		flag = 1
		ascend = True
print(ans)


n = int(input())
a = list(map(int, input().split()))
idx = sorted(range(n), key=lambda i: a[i], reverse=True)
left = 1
right = 1
ok = True
for cur in idx[1:]:
	if cur > idx[0]:
		if cur - idx[0] == right:
			right += 1
		else:
			ok = False
	if cur < idx[0]:
		if idx[0] - cur == left:
			left += 1
		else:
			ok = False
print('YES' if ok else 'NO')


n = int(input())
arr = list(map(int, input().strip().split()))
m = 0
argMax = -1
for i in range(n):
	if arr[i] > m:
		m = arr[i]
		argMax = i
res = 'YES'
for i in range(argMax - 1):
	if arr[i] > arr[i + 1]:
		res = 'NO'
		break
for i in range(argMax, n - 1):
	if arr[i] < arr[i + 1]:
		res = 'NO'
		break
print(res)


n = int(input())
dsk = [int(x) for x in input().split()]
lst = [x for x in dsk]
lst.sort(reverse=True)
max_idx = dsk.index(max(dsk))
r = max_idx + 1
l = max_idx - 1
flag = 0
for i in range(1, n):
	if l >= 0 and lst[i] == dsk[l]:
		l -= 1
	elif r < n and lst[i] == dsk[r]:
		r += 1
	else:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input().strip())
nums = [int(i) for i in input().strip().split()]
the_max = max(nums)
max_index = 0
for i in range(n):
	if nums[i] == the_max:
		max_index = i
		break
left_index = max_index
right_index = max_index
current_large = the_max
possible = True
while True:
	if right_index == n - 1:
		while left_index > 0:
			if nums[left_index - 1] < current_large:
				current_large = nums[left_index - 1]
				left_index -= 1
			else:
				possible = False
				break
		break
	if left_index == 0:
		while right_index < n - 1:
			if nums[right_index + 1] < current_large:
				current_large = nums[right_index + 1]
				right_index += 1
			else:
				possible = False
				break
		break
	if nums[left_index - 1] > nums[right_index + 1]:
		if nums[left_index - 1] < current_large:
			current_large = nums[left_index - 1]
			left_index -= 1
		else:
			possible = False
			break
	elif nums[left_index - 1] < nums[right_index + 1]:
		if nums[right_index + 1] < current_large:
			current_large = nums[right_index + 1]
			right_index += 1
		else:
			possible = False
			break
	else:
		possible = False
		break
print('YES' if possible else 'NO')


def main():
	n = int(input())
	line = input().split()
	v = [int(x) for x in line]
	pos = -1
	for i in range(n):
		if v[i] == n:
			pos = i
	(lo, hi) = (pos - 1, pos + 1)
	goal = n - 1
	ok = True
	while goal > 0 and ok:
		if lo >= 0:
			if v[lo] == goal:
				lo -= 1
				goal -= 1
				continue
		if hi < n:
			if v[hi] == goal:
				hi += 1
				goal -= 1
				continue
		ok = False
	if ok:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
arr = list(map(int, input().split()))
max_idx = arr.index(max(arr))
is_possible = True
if len(set(arr)) != n:
	is_possible = False
if is_possible:
	for i in range(max_idx, 0, -1):
		if arr[i] <= arr[i - 1]:
			is_possible = False
			break
	for i in range(max_idx, n - 1):
		if arr[i] <= arr[i + 1]:
			is_possible = False
			break
print('YES' if is_possible else 'NO')


import io, sys
input = lambda f=io.StringIO(sys.stdin.buffer.read().decode()).readline: f().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
a = li()
p = a.index(max(a))
b = sorted(a)
b.pop()
ok = 1
(i, j) = (p - 1, p + 1)
while i >= 0 or j < n:
	if i >= 0 and a[i] == b[-1]:
		b.pop()
		i -= 1
	elif j < n and a[j] == b[-1]:
		b.pop()
		j += 1
	else:
		ok = 0
		break
print('YES' if ok else 'NO')


n = int(input())
a = [int(i) for i in input().split()]
highest = a.index(n)
number = 0
flag = False
for i in range(n):
	if i <= highest:
		if number >= a[i]:
			print('NO')
			break
		else:
			number = a[i]
	elif number <= a[i]:
		print('NO')
		break
	else:
		number = a[i]
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
pre = a[0]
if a[0] >= a[1]:
	g = 1
else:
	g = 0
pg = 0
flag = 0
for i in range(1, n):
	if pre >= a[i]:
		pg = g
		g = 1
	else:
		pg = g
		g = 0
	if pg == 1 and g == 0:
		flag = 1
		break
	pre = a[i]
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
x = len(l)
comp = []
ls = 0
rs = x - 1
while ls < rs:
	if l[ls] < l[rs]:
		comp.append(l[ls])
		ls += 1
	else:
		comp.append(l[rs])
		rs -= 1
comp.append(l[ls])
flag = 0
for i in range(n - 1):
	flag = 0
	if comp[i] > comp[i + 1]:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')


from heapq import heappush, heappop
n = int(input())
a = list(map(int, input().split()))
que = []
ma = max(a)
(l, r) = (-1, -1)
for i in range(n):
	if a[i] == ma:
		(l, r) = (i, i)
		continue
	else:
		heappush(que, (-a[i], i))
while que:
	(q, i) = heappop(que)
	if i == l - 1:
		l -= 1
	elif i == r + 1:
		r += 1
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
l = [int(x) for x in input().split()]
i = l.index(max(l))
if l[:i] != sorted(l[:i]):
	print('NO')
	exit(0)
if l[i + 1:][::-1] != sorted(l[i + 1:]):
	print('NO')
	exit(0)
print('YES')


n = int(input())
a = list(map(int, input().strip().split()))
maxi = 0
mx = 0
for i in range(n):
	if a[i] > mx:
		mxi = i
		mx = a[i]
f = 1
prev = mx
for i in range(mxi, n):
	if a[i] <= prev:
		prev = a[i]
		continue
	f = 0
prev = 0
for i in range(0, mxi):
	if a[i] >= prev:
		prev = a[i]
		continue
	f = 0
if f:
	print('YES')
else:
	print('NO')


n = int(input())
s = [int(x) for x in input().split()]
pos = [0] * (n + 1)
for i in range(0, len(s)):
	pos[s[i]] = i
ptr1 = pos[-1]
ptr2 = pos[-1]
trg = pos[-1]
temp = 0
for i in range(len(pos) - 2, 0, -1):
	if pos[i] > trg:
		if pos[i] - ptr2 == 1:
			ptr2 += 1
		else:
			temp = 1
			break
	elif ptr1 - pos[i] == 1:
		ptr1 -= 1
	else:
		temp = 1
		break
if temp == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(j) for j in input().split()]
c1 = 0
c2 = 0
i = 0
for i in range(n - 1):
	if a[i] > a[i + 1]:
		c1 = 1
		break
if c1 == 1:
	for j in range(i, n - 1):
		if a[j] < a[j + 1]:
			c2 = 1
			break
if c2 == 1:
	print('NO')
else:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
x = a.index(max(a))
lis1 = a[0:x]
lis2 = a[x + 1:n]
t1 = sorted(lis1)
t2 = sorted(lis2, reverse=True)
c1 = 0
c2 = 0
s = 0
if len(t1) == 0:
	c1 = 1
if len(t2) == 0:
	c2 = 1
for i in range(len(t1)):
	if lis1[i] == t1[i]:
		s += 1
if len(t1) == s:
	c1 = 1
s = 0
for i in range(len(t2)):
	if lis2[i] == t2[i]:
		s += 1
if len(t2) == s:
	c2 = 1
if c1 == 1 and c2 == 1:
	print('YES')
else:
	print('NO')


n = int(input())
ls = list(map(int, input().split()))
k = ls.index(max(ls))
ls1 = ls[:k + 1]
ls2 = ls[k:]
if sorted(ls1) == ls1 and sorted(ls2, reverse=True) == ls2:
	print('YES')
else:
	print('NO')


n = int(input())
lst = list(map(int, input().strip().split()))
f = True
for i in range(1, n - 1):
	if lst[i - 1] > lst[i] and lst[i] < lst[i + 1]:
		f = False
		break
if f == True:
	print('YES')
else:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
flag = False
mx = arr.index(max(arr))
l1 = arr[:mx]
l2 = arr[mx + 1:]
if sorted(l1) == arr[:mx] and sorted(l2, reverse=True) == arr[mx + 1:]:
	flag = True
if flag == True:
	print('YES')
else:
	print('NO')


def mp():
	return map(int, input().split())
n = int(input())
a = list(mp())
max_i = a.index(max(a))
fail = False
for i in range(1, max_i):
	if a[i - 1] > a[i]:
		fail = True
for i in range(max_i, n - 1):
	if a[i] < a[i + 1]:
		fail = True
if fail:
	print('NO')
else:
	print('YES')


n = int(input())
l = list(map(int, input().split()))
ans = []
z = max(l)
ans.append(z)
index = 0
for i in range(len(l)):
	if l[i] == z:
		index = i
		break
i = index - 1
j = index + 1
while i >= 0 and j < n:
	if l[i] > l[j] and l[i] < ans[-1]:
		ans.append(l[i])
		i -= 1
	elif l[i] < l[j] and l[j] < ans[-1]:
		ans.append(l[j])
		j += 1
	else:
		break
while i >= 0:
	if l[i] < ans[-1]:
		ans.append(l[i])
		i -= 1
	else:
		break
while j < n:
	if l[j] < ans[-1]:
		ans.append(l[j])
		j += 1
	else:
		break
if sorted(ans) == sorted(l):
	print('YES')
else:
	print('NO')


n = int(input())
L = [int(x) for x in input().split()]
for i in range(n):
	if L[i] == n:
		break
T = L[:i]
J = L[i + 1:]
if sorted(T) == T and sorted(J, reverse=True) == J:
	print('Yes')
else:
	print('NO')


n = int(input())
l = input().split()
li = [int(i) for i in l]
copy = list(li)
copy.sort()
start = 0
end = n - 1
poss = 1
for i in range(n):
	if li[start] == copy[i]:
		start += 1
		continue
	if li[end] == copy[i]:
		end -= 1
		continue
	poss = 0
	break
if poss:
	print('yes')
else:
	print('no')


import sys
n = int(input())
a = [int(x) for x in input().split()]
m = max(a)
mi = a.index(m)
le = mi - 1
ri = mi + 1
for i in range(n - 1, 0, -1):
	found = False
	if le >= 0 and a[le] == i:
		le -= 1
		found = True
	if ri < n and a[ri] == i:
		ri += 1
		found = True
	if not found:
		print('NO')
		sys.exit()
print('YES')


def isDesc(lt, st, ed):
	for i in range(st + 1, ed):
		if lt[i] > lt[i - 1]:
			return False
	return True

def isAsc(lt, st, ed):
	for i in range(st + 1, ed):
		if lt[i] < lt[i - 1]:
			return False
	return True
n = int(input())
lt = list(map(int, input().split()))
mi = lt.index(max(lt))
if isAsc(lt, 0, mi) and isDesc(lt, mi + 1, len(lt)):
	print('yes')
else:
	print('no')


from sys import stdin
input = stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
actual = 0
while actual < n - 1 and a[actual] < a[actual + 1]:
	actual += 1
while actual < n - 1 and a[actual] > a[actual + 1]:
	actual += 1
if actual == n - 1:
	print('YES')
else:
	print('NO')


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


p = int(input())
l = list(map(int, input().split()))
index = l.index(max(l))
if l[:index] == sorted(l[:index]) and l[index + 1:] == sorted(l[index + 1:])[::-1]:
	print('yes')
else:
	print('No')


n = int(input())
a = [int(x) for x in input().split(' ')]
isLower = False
last = -1
valid = True
for i in a:
	if not isLower:
		if i < last:
			isLower = True
	elif i > last:
		valid = False
		break
	last = i
print('YES' if valid else 'NO')


number = input()
lengths = list(map(int, input().split()))
max_index = lengths.index(max(lengths))
left_side = lengths[0:max_index]
if left_side == sorted(left_side):
	right_side = lengths[max_index + 1:]
	if right_side == sorted(right_side, reverse=True):
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def f(ar):
	if ar == []:
		return 1
	for i in range(1, len(ar)):
		if ar[i] <= ar[i - 1]:
			return 0
	return 1
n = int(input())
a = list(map(int, input().split()))
ind = 0
for i in range(n):
	if a[i] == n:
		ind = i
		break
t = a[ind + 1:n]
if f(a[:ind]) and f(t[::-1]):
	print('Yes')
else:
	print('No')


n = int(input())
l = input().split(' ')
l = list(map(int, l))
m = max(l)
pos = l.index(m)
l2 = []
l3 = []
for i in range(0, pos):
	l2.append(l[i])
for j in range(pos + 1, n):
	l3.append(l[j])
flag = 0
flag2 = 0
l4 = l2[:]
l4.sort()
if l4 == l2:
	flag = 1
l5 = l3[:]
l5.sort()
l5.reverse()
if l5 == l3:
	flag2 = 1
if flag == 1 and flag2 == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout

def input():
	input.IT += 1
	return input.lines[input.IT - 1][:-1]
input.IT = 0
input.lines = stdin.readlines()

def print(*arg):
	print.out.append(' '.join((str(i) for i in arg)))
print.out = []
n = int(input())
a = list(map(int, input().split()))
m = a.index(max(a))
i = m - 1
j = m + 1
while i >= 0 and j < n and (a[m] > max(a[i], a[j])):
	if a[i] > a[j]:
		a[m] = a[i]
		i -= 1
	else:
		a[m] = a[j]
		j += 1
ans = True
while i >= 0:
	if a[m] < a[i]:
		ans = False
		break
	a[m] = a[i]
	i -= 1
while j < n:
	if a[m] < a[j]:
		ans = False
		break
	a[m] = a[j]
	j += 1
print('YES' if ans else 'NO')
stdout.write('\n'.join(print.out))


n = int(input())
a = list(map(int, input().split()))
pre = 0
is_down = False
for i in a:
	if i > pre and is_down is True:
		print('NO')
		exit(0)
	if i < pre:
		is_down = True
	pre = i
print('YES')


n = int(input())
a = list(map(int, input().split()))
m = max(a)
k = a.index(m)
l = k
r = k + 1
flag = True
while (l > 0) + (r < n):
	if l == 0:
		if r == n:
			flag = True
			break
		elif a[r] < m:
			m = a[r]
			r += 1
		else:
			flag = False
			break
	elif r == n:
		if a[l - 1] < m:
			l -= 1
			m = a[l]
		else:
			flag = False
			break
	elif a[l - 1] > a[r]:
		if a[l - 1] >= m:
			flag = False
			break
		else:
			l -= 1
			m = a[l]
	elif a[r] >= m:
		flag = False
		break
	else:
		m = a[r]
		r += 1
if flag:
	print('yes')
else:
	print('no')


n = int(input())
A = [int(i) for i in input().split()]
incfirst = 1
decnext = 1
ok = 1
for i in range(n - 1):
	if A[i] < A[i + 1] and incfirst == 1:
		continue
	elif incfirst == 1:
		incfirst = 2
	elif incfirst == 2 and A[i] < A[i + 1]:
		decnext = 0
	elif incfirst == 2 and A[i] > A[i + 1]:
		continue
if incfirst >= 1 and decnext == 1 and ok:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
li = l.index(n)
ri = li
ind = [-1 for i in range(n)]
for (i, x) in enumerate(l):
	ind[x - 1] = i
ans = True
for i in range(n - 1, 0, -1):
	p = ind[i - 1]
	if p == li - 1:
		li -= 1
	elif p == ri + 1:
		ri += 1
	else:
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


N = int(input())
if N == 0:
	print('NO')
else:
	A = input().split()
	A = map(int, A)
	A = list(A)
	mmm = -1
	I = -1
	for i in range(0, N):
		if mmm < A[i]:
			I = i
			mmm = A[i]
	b = True
	for i in range(0, I):
		if A[i] > A[i + 1]:
			b = False
	if N - 1 - I - 1 >= 1:
		for i in range(I + 1, N - 1):
			if A[i] < A[i + 1]:
				b = False
	if b:
		print('YES')
	else:
		print('NO')


from collections import deque

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
n = ii()
a = li()
f = 0
x = a.index(max(a))
for i in range(1, x):
	if a[i] < a[i - 1]:
		f = 1
		break
for i in range(n - 2, x, -1):
	if a[i] < a[i + 1]:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')


x = int(input())
l = list(map(int, input().split()))
a = max(l)
b = l.index(a)
d = l[:b + 1]
p = l[b + 1:]
if sorted(d) == d and p == sorted(p)[::-1]:
	print('YES')
else:
	print('NO')


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


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


n = int(input())
a = list(map(int, input().split()))
i = a.index(max(a))
x = 1
for j in range(i, 0, -1):
	if a[j - 1] >= a[j]:
		x = 0
for j in range(i + 1, n):
	if a[j] >= a[j - 1]:
		x = 0
print('YES' if x else 'NO')


import sys
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
n = int(input())
arr = intInp()
inc = True
dec = True
failed = False
for i in range(n - 1):
	if arr[i] > arr[i + 1]:
		inc = False
	if inc == False:
		if arr[i] < arr[i + 1]:
			failed = True
if failed:
	print('No')
else:
	print('Yes')


import sys

class BPillars:

	def solve(self):
		n = int(input())
		a = [int(_) for _ in input().split()]
		k = a.index(max(a))
		cur = n - 1
		(l, r) = (k - 1, k + 1)
		while l != -1 or r != n:
			if l != -1 and a[l] == cur:
				l -= 1
			elif r != n and a[r] == cur:
				r += 1
			else:
				print('NO')
				break
			cur -= 1
		else:
			print('YES')
solver = BPillars()
input = sys.stdin.readline
solver.solve()


n = int(input())
a = list(map(int, input().split()))
M = max(a)
i = a.index(M)
c = 0
test1 = all((x < y for (x, y) in zip(a[0:i], a[1:])))
test2 = all((x > y for (x, y) in zip(a[i:], a[i + 1:])))
if test1 == True and test2 == True:
	print('YES')
else:
	print('NO')


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
t = ii()
d = li()
pos = [0] * (t + 1)
for i in range(t):
	pos[d[i]] = i
m = pos[t]
i = m - 1
j = m + 1
n = t
f = True
while i >= 0 or j < t:
	if i >= 0:
		if d[i] == n - 1:
			i -= 1
			n -= 1
			continue
	if j < t:
		if d[j] == n - 1:
			j += 1
			n -= 1
			continue
	f = False
	break
print('YES') if f else print('NO')


n = int(input())
arr = list(map(int, input().split()))
m = arr.index(max(arr))
i = m
ans = 'YES'
while i:
	if arr[i - 1] > arr[i]:
		ans = 'NO'
	i -= 1
i = m
while i < len(arr) - 1:
	if arr[i + 1] > arr[i]:
		ans = 'NO'
	i += 1
print(ans)


m = int(input())
l = list(map(int, input().split()))
ma = max(l)
for i in range(0, m):
	if l[i] == ma:
		p = i
		break
f = 0
for i in range(p, m - 1):
	if l[i] <= l[i + 1]:
		f = 1
		break
for j in range(1, p + 1):
	if l[j - 1] >= l[j]:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')


n = int(input())
x = list(map(int, input().split()))
y = []
for i in range(1, n - 1):
	if x[i - 1] > x[i] and x[i + 1] > x[i]:
		y.append(1)
	else:
		y.append(0)
if sum(y) > 0:
	print('NO')
else:
	print('YES')


n = int(input())
ls = list(map(int, input().split()))
m = ls.index(max(ls))
l = ls[:m]
l2 = ls[m:]
if l == sorted(l) and l2 == sorted(l2, reverse=True):
	print('YES')
else:
	print('NO')


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n - 1):
	if a[i - 1] > a[i] and a[i + 1] > a[i]:
		print('NO')
		exit(0)
print('YES')


n = int(input())
a = [int(i) for i in input().split()]
c = a.index(max(a))
count = 0
for i in range(1, c + 1):
	if a[i] > a[i - 1]:
		continue
	else:
		count = 1
		break
if count == 0:
	for i in range(c, n - 1):
		if a[i] > a[i + 1]:
			continue
		else:
			count = 1
print(('YES', 'NO')[count == 1])


n = int(input())
pillars = [int(item) for item in input().split(' ')]
max_ptr = -1
for i in range(n):
	if pillars[i] == n:
		max_ptr = i
		break
left = max_ptr - 1
right = max_ptr + 1
search = n - 1
ans = 'YES'
while left >= 0 or right < n:
	if left >= 0 and pillars[left] == search:
		left -= 1
	elif right < n and pillars[right] == search:
		right += 1
	else:
		ans = 'NO'
		break
	search -= 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = a.copy()
c = a.copy()
k1 = sorted(b[:a.index(n)])
k2 = sorted(c[a.index(n):], reverse=True)
if a == k1 + k2:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
maxPosition = a.index(max(a))
flag = True
for i in range(maxPosition):
	if a[i] > a[i + 1]:
		flag = False
for i in range(maxPosition, n - 1):
	if a[i] < a[i + 1]:
		flag = False
print('YES') if flag == True else print('NO')


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
rost = True
for i in range(1, n):
	if rost:
		if a[i] < a[i - 1]:
			rost = False
	elif a[i] > a[i - 1]:
		exit(print('NO'))
print('YES')


n = int(input())
a = list(map(int, input().split()))
m1 = max(a)
i = a.index(m1)
b = a[:i]
c = a[i + 1:]
b.sort()
c.sort()
if a[:i] == b and a[i + 1:] == c[::-1]:
	print('YES')
else:
	print('NO')


pillars = int(input())
l = [int(x) for x in input().split()]
max_index = 0
max_k = 0
flag = True
for i in range(pillars):
	if l[i] > max_k:
		max_index = i
		max_k = l[i]
for i in range(max_index):
	if l[i] > l[i + 1]:
		flag = False
		break
for i in range(max_index, pillars - 1):
	if l[i] < l[i + 1]:
		flag = False
		break
print('yes') if flag else print('no')


from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().strip().split()))
max_elem = max(a)
left = a[:a.index(max_elem)]
right = a[a.index(max_elem):]
if left != sorted(left) or right != list(reversed(sorted(right))):
	print('NO')
else:
	print('YES')


n = int(input())
lis = [int(x) for x in input().split()]
for i in range(n):
	if lis[i] == n:
		p = i
ok = True
for i in range(1, p):
	if lis[i] < lis[i - 1]:
		ok = False
for i in range(p, n - 1):
	if lis[i] < lis[i + 1]:
		ok = False
if ok:
	print('YES')
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
ind = l.index(max(l))
l1 = l[:ind]
l2 = l[ind + 1:]
if l1 == sorted(l1) and l2 == sorted(l2, reverse=True):
	print('yes')
else:
	print('no')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
a = Ri()
(maxind, maxx) = (-1, -1)
for i in range(n):
	if a[i] > maxx:
		maxx = a[i]
		maxind = i
flag = True
for i in range(1, maxind + 1):
	if a[i] < a[i - 1]:
		flag = False
		break
for i in range(maxind + 1, n - 1):
	if a[i] < a[i + 1]:
		flag = False
		break
if not flag:
	NO()
else:
	YES()


def isdesc(a):
	b = a.copy()
	b.sort(reverse=True)
	if a == b:
		return True
	else:
		return False
n = int(input())
a = list(map(int, input().split()))
f = True
ind = a.index(max(a))
a1 = a[:ind][::-1]
a2 = a[ind + 1:]
if isdesc(a1) and isdesc(a2):
	print('YES')
else:
	print('NO')


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
L = list(map(int, input().split()))
L_sorted = sorted(L, reverse=True)
max_ind = L.index(L_sorted[0])
left = max_ind - 1
right = max_ind + 1
ans = 'YES'
for l in L_sorted[1:]:
	if left >= 0 and L[left] == l:
		left -= 1
	elif right < N and L[right] == l:
		right += 1
	else:
		ans = 'NO'
		break
print(ans)


import sys
n = int(input())
a = list(map(int, input().rstrip().split()))
mx = max(a)
mx_index = a.index(mx)
for i in range(mx_index, n - 1):
	if a[i] > a[i + 1]:
		pass
	else:
		print('NO')
		sys.exit()
for i in range(mx_index, 0, -1):
	if a[i] > a[i - 1]:
		pass
	else:
		print('NO')
		sys.exit()
print('YES')


n = int(input())
radius = list(map(int, input().split()))
flag = 1
p = max(radius)
q = radius.index(p)
for i in range(q):
	if radius[i + 1] < radius[i]:
		flag = 0
for i in range(q, n - 1):
	if radius[i + 1] > radius[i]:
		flag = 0
if flag == 1:
	print('YES')
else:
	print('NO')


def find(A):
	O = A[:]
	A = sorted([(A[i], i) for i in range(len(A))])
	dic = {}
	for i in range(len(A)):
		if A[i][0] in dic:
			return 'NO'
		else:
			dic[A[i][0]] = i
	pos = []
	for i in range(len(O)):
		pos += [dic[O[i]]]
	rev_pos = {}
	for i in range(len(pos)):
		rev_pos[pos[i]] = i
	left = rev_pos[len(A) - 1]
	right = rev_pos[len(A) - 1]
	for i in range(len(A) - 2, -1, -1):
		now_pos = rev_pos[i]
		if now_pos == left - 1:
			left = now_pos
		elif now_pos == right + 1:
			right = right + 1
		else:
			return 'NO'
	return 'YES'
input()
print(find(list(map(int, input().strip().split(' ')))))


n = int(input())
a = list(map(int, input().split()))
a1 = max(a)
y1 = a.index(a1)
b = [a[j] for j in range(len(a[:y1]))]
b.sort()
c = [a[y1 + 1 + j] for j in range(len(a[y1 + 1:]))]
c.sort(reverse=True)
if a[:y1] == b and c == a[y1 + 1:]:
	print('YES')
else:
	print('NO')


pillars = int(input())
values = [int(x) for x in input().split()]
coorMax = values.index(max(values))
left = values[:coorMax]
right = values[coorMax + 1:]
leftSize = len(left)
rightSize = len(right)
first = True
if leftSize > 1:
	first = False
	for i in range(1, leftSize):
		if left[i] < left[i - 1]:
			break
		if i == leftSize - 1:
			first = True
second = True
if rightSize > 1:
	second = False
	for i in range(0, rightSize - 1):
		if right[i] < right[i + 1]:
			break
		if i == rightSize - 2:
			second = True
if first and second:
	print('YES')
else:
	print('NO')


mod = 1000000007
mod1 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
l2 = sorted(l)[::-1]
i = l.index(l2[0]) - 1
j = i + 2
for k in l2[1:]:
	if -1 < i < n and l[i] == k:
		i -= 1
	elif -1 < j < n and l[j] == k:
		j += 1
	else:
		exit(print('NO'))
print('YES')


def program():
	n = int(input())
	l = list(map(int, input().split()))
	state = 0
	for i in range(n - 1):
		if l[i] > l[i + 1] and state == 0:
			state = 1
		if l[i] < l[i + 1] and state == 1:
			state = 4
			break
	if state == 4:
		print('NO')
	else:
		print('YES')
program()


n = int(input())
p = input().rstrip().split(' ')
if len(list(set(p))) != len(p):
	print('NO')
else:
	l = []
	for i in range(0, len(p)):
		l.append(int(p[i]))
	T = max(l)
	G = 0
	A = l.index(T)
	for i in range(0, A - 1):
		if int(l[i]) < int(l[i + 1]):
			continue
		else:
			G = 1
			break
	if G == 1:
		print('NO')
	else:
		for i in range(A, len(l) - 1):
			if int(l[i]) > int(l[i + 1]):
				continue
			else:
				G = 1
				break
		if G == 1:
			print('NO')
		else:
			print('YES')


import math
x = input()
x = int(x)
numbers = list(map(int, input().split()))
m = numbers.index(max(numbers))
L = numbers[:m]
R = numbers[m + 1:]
L2 = L.copy()
R2 = R.copy()
R2.reverse()
L.sort()
R.sort()
if L != L2:
	print('No')
	exit()
if R != R2:
	print('No')
	exit()
print('Yes')


from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split(' ')]
m = 0
m_i = None
c = defaultdict(int)
for i in range(len(a)):
	if m < a[i]:
		m = a[i]
		m_i = i
	c[a[i]] += 1
if len(set(c.values())) != 1:
	print('NO')
	exit()
if next(iter(c.values())) != 1:
	print('NO')
	exit()
for i in range(1, m_i):
	if a[i] <= a[i - 1]:
		print('NO')
		exit()
for i in range(m_i + 1, n - 1):
	if a[i] <= a[i + 1]:
		print('NO')
		exit()
print('YES')


n = int(input())
a = list(map(int, input().split()))
t = a.index(n)
res = True
for i in range(1, t):
	res &= a[i] > a[i - 1]
for i in range(t, n - 1):
	res &= a[i] > a[i + 1]
print('YNEOS'[not res::2])


n = int(input())
arr = list(map(int, input().split()))
lpos = arr.index(max(arr))
okay = True
for i in range(lpos):
	if not okay:
		break
	okay = okay & (arr[i] < arr[i + 1])
for i in range(lpos, n - 1):
	if not okay:
		break
	okay = okay & (arr[i] > arr[i + 1])
if okay:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(o) for o in input().split()]
mai = a.index(max(a))
a1 = a[:mai]
a2 = a[mai + 1:]
a1.sort()
a2.sort()
a2 = a2[::-1]
if a1 + [a[mai]] + a2 == a:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
compression_dict = {a: ind for (ind, a) in enumerate(sorted(set(A)))}
A = [compression_dict[a] for a in A]
MAX = max(A)
from collections import deque
QUE = deque()
for a in A:
	QUE.append(a)
	while len(QUE) >= 2 and (QUE[-1] == MAX or QUE[-2] == MAX) and (abs(QUE[-1] - QUE[-2]) <= 1):
		x = QUE.pop()
		y = QUE.pop()
		QUE.append(min(x, y))
		MAX -= 1
if len(QUE) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
x = max(a)
p = q = r = 0
c = 1
for i in range(n):
	if x == a[i]:
		p = i
q = p - 1
r = p + 1
y = z = -1
flag = True
while c < n:
	x = x - 1
	if q >= 0:
		y = a[q]
	else:
		y = -1
	if r < n:
		z = a[r]
	else:
		z = -1
	if y > 0 and y == x:
		c += 1
		q -= 1
	elif z > 0 and z == x:
		c += 1
		r += 1
	else:
		flag = False
		break
if flag == True:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	for i in range(n - 1):
		if a[i] == n:
			flag = False
			continue
		if flag == False and a[i] < a[i + 1]:
			print('NO')
			return
		elif flag == True and a[i] > a[i + 1]:
			print('NO')
			return
	print('YES')
	return
	return
main()


from collections import deque
n = int(input())
radius = list(map(int, input().split()))
for i in range(n):
	radius[i] = (radius[i], i, i)
radius.sort(reverse=True)
deque_of_radius = deque()
for i in radius:
	deque_of_radius.append((i[0], i[1], i[2]))
answer = False
for i in range(n - 1):
	(now, left, right) = deque_of_radius.popleft()
	(last, last_left, last_right) = deque_of_radius.popleft()
	if left - last_right == 1:
		deque_of_radius.appendleft((now, left - 1, right))
	elif last_left - right == 1:
		deque_of_radius.appendleft((now, left, right + 1))
	else:
		answer = True
		print('NO')
		break
if not answer:
	print('YES')


n = int(input())
a = list(map(int, input().split()))
if len(set(a)) < n:
	print('NO')
else:
	m = a[0]
	mPosition = 0
	for i in range(1, n):
		if a[i] > m:
			m = a[i]
			mPosition = i
	a1 = a[:mPosition]
	a2 = a[mPosition + 1:]
	if sorted(a1) == a1 and sorted(a2, reverse=True) == a2:
		print('YES')
	else:
		print('NO')


import math
n = int(input())
list = [int(i) for i in input().split()]
val = max(list) - 1
ind = list.index(val + 1)
(l, r) = (ind - 1, ind + 1)
while val > 0:
	if l >= 0 and list[l] == val:
		l -= 1
		val -= 1
	elif r < n and list[r] == val:
		r += 1
		val -= 1
	else:
		print('NO')
		exit()
print('YES')


import sys
n = int(input())
arr = list(map(int, input().split()))
flag = 0
for i in range(n - 1):
	if arr[i] > arr[i + 1]:
		flag = 1
	if arr[i] < arr[i + 1] and flag:
		print('NO')
		sys.exit()
print('YES')


def main():
	n = int(input())
	lista = list(map(int, input().split()))
	at = lista[0]
	i = 0
	while at != n:
		if lista[i + 1] < at:
			print('NO')
			return
		i += 1
		at = lista[i]
	while i < len(lista) - 1:
		if lista[i + 1] > at:
			print('NO')
			return
		i += 1
		at = lista[i]
	print('YES')
main()


n = int(input())
arr = list(map(int, input().split()))
con = 0
stat = 1
for x in range(n - 1):
	if arr[x] > arr[x + 1]:
		con = 1
	if con == 1 and arr[x] < arr[x + 1]:
		stat = 0
		break
if stat:
	print('YES')
else:
	print('NO')


n = int(input())
a = [int(x) for x in input().split()]
m = max(a)
m_idx = a.index(m)
possible = True
for i in range(1, m_idx):
	if a[i] < a[i - 1]:
		possible = False
for i in range(m_idx + 2, n):
	if a[i] > a[i - 1]:
		possible = False
print('YES') if possible else print('NO')


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math
n = getN()
nums = getList()
mx = max(nums)
up = True
ans = 'YES'
tmp = 0
for num in nums:
	if up:
		if num <= tmp:
			ans = 'NO'
		tmp = num
		if num == mx:
			up = False
	else:
		if num >= tmp:
			ans = 'NO'
		tmp = num
print(ans)


n = int(input())
arr = list(map(int, input().split()))
i = 0
j = len(arr) - 1
s = 0
while i < j:
	if arr[i] < arr[i + 1]:
		i += 1
		s = i
	else:
		s = i
		break
s1 = j
while j > 0:
	if arr[j] < arr[j - 1]:
		j -= 1
		s1 = j
	else:
		s1 = j
		break
if s == s1:
	print('YES')
else:
	print('NO')


n = int(input())
x = list(map(int, input().split()))
g = x.index(max(x))
flag = 0
for i in range(g - 1):
	if x[i] > x[i + 1]:
		flag = 1
		break
for i in range(g, n - 1):
	if x[i] < x[i + 1]:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


x = i = 0
j = int(input()) - 1
a = (*map(int, input().split()),)
while i < j and x < min(a[i], a[j]):
	if a[i] < a[j]:
		x = a[i]
		i += 1
	else:
		x = a[j]
		j -= 1
print('YNEOS'[i < j::2])


import sys
n = int(input())
A = list(map(int, input().split()))
max_idx = 0
for i in range(1, n):
	if A[i] > A[max_idx]:
		max_idx = i
for i in range(max_idx - 1, -1, -1):
	if A[i] > A[i + 1]:
		print('NO')
		sys.exit()
for i in range(max_idx + 1, n):
	if A[i] > A[i - 1]:
		print('NO')
		sys.exit()
print('YES')


n = int(input())
data = [int(i) for i in input().split()]
ind = [0] * (n + 1)
for i in range(n):
	ind[data[i]] = i
li = ind[n] - 1
ri = ind[n] + 1
good = True
for i in range(n - 1, 0, -1):
	if ind[i] == ri:
		ri += 1
		continue
	if ind[i] == li:
		li -= 1
		continue
	good = False
	break
if good:
	print('YES')
else:
	print('NO')


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


n = int(input())
a = [int(i) for i in input().split()]
max_index = 0
flag = 0
for i in range(1, n):
	if a[i] > a[max_index]:
		max_index = i
for i in range(max_index - 1, -1, -1):
	if a[i] >= a[i + 1]:
		flag = 1
		break
for i in range(max_index + 1, n):
	if a[i] >= a[i - 1]:
		flag = 1
		break
if flag:
	print('No')
else:
	print('Yes')


n = int(input())
lis = list(map(int, input().split()))
m = max(lis)
k = lis.index(m)
m -= 1
if k == 0:
	j = 1
	while j < n and lis[j] == m:
		m -= 1
		j += 1
	if j == n:
		print('YES')
	else:
		print('NO')
	exit()
if k == n - 1:
	i = n - 2
	while i >= 0 and lis[i] == m:
		m -= 1
		i -= 1
	if i == -1:
		print('YES')
	else:
		print('NO')
	exit()
i = k - 1
j = k + 1
while i >= 0 or j < n:
	if i >= 0 and lis[i] == m:
		i -= 1
	elif j < n and lis[j] == m:
		j += 1
	else:
		print('NO')
		exit()
	m -= 1
print('YES')