We have one slime.
You can set the health of this slime to any integer value of your choice.
A slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.
Determine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.
Here S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 18
 - 1 \leq S_i \leq 10^9

-----Input-----
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_{2^N}

-----Output-----
If it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.

-----Sample Input-----
2
4 2 3 1

-----Sample Output-----
Yes

We will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.
First, set the health of the first slime to 4.
By letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.
Then, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
def main():
	N = int(input())
	S = list(map(int, input().split()))
	INF = float('inf')
	S.sort()
	parents = [S[-1]]
	S[-1] = INF
	for _ in range(N):
		checking = 2
		parents.sort(reverse=True)
		for i in parents[:]:
			while True:
				if S[-checking] < i:
					parents.append(S[-checking])
					S[-checking] = INF
					break
				else:
					checking += 1
				if checking == 2 ** N + 1:
					print('No')
					return
	else:
		print('Yes')

def __starting_point():
	main()
__starting_point()


N = int(input())
N2 = 2 ** N
S = list(map(int, input().split()))
S.sort(reverse=True)
slimes = [S[0]]
S[0] = float('inf')
num = 1
for i in range(N):
	slimes.sort()
	n = num
	idx = 0
	while n and idx <= N2 - 1:
		if S[idx] < slimes[n - 1]:
			slimes.append(S[idx])
			S[idx] = float('inf')
			idx += 1
			n -= 1
		else:
			idx += 1
	if n:
		print('No')
		return
	num *= 2
print('Yes')


N = int(input())
S = list(map(int, input().split()))
S.sort()
parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []
	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]
if len(parent) == 2 ** N:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	s = sorted(list(map(int, input().strip().split())), reverse=True)
	check = [False] * 2 ** N
	now = []
	now.append([s[0], 1])
	check[0] = True
	ok = True
	for i in range(N):
		next_ = []
		tmp = 0
		for j in range(len(now)):
			(hp, start) = now[j]
			start = max(start, tmp)
			ok = False
			for k in range(start, 2 ** N):
				if s[k] < hp and (not check[k]):
					tmp = k + 1
					now[j][1] = k + 1
					check[k] = True
					next_.append([s[k], k + 1])
					ok = True
					break
			if not ok:
				break
		now += next_
		now = sorted(now, reverse=True)
		if not ok:
			break
	if ok:
		print('Yes')
	else:
		print('No')

def __starting_point():
	main()
__starting_point()


def main():
	n = int(input())
	s = list(map(int, input().split(' ')))
	s = sorted(s)[::-1]
	slimes = [s[0]]
	s = s[1:]
	for i in range(n):
		make_slimes = []
		rest_slimes = []
		make_idx = 0
		for j in range(2 ** i):
			for tmp_make_idx in range(make_idx, len(s)):
				if slimes[j] > s[tmp_make_idx]:
					make_slimes.append(s[tmp_make_idx])
					break
				else:
					rest_slimes.append(s[tmp_make_idx])
			make_idx = tmp_make_idx + 1
		rest_slimes += s[make_idx:]
		if len(make_slimes) < 2 ** i:
			print('No')
			return
		slimes += make_slimes
		s = rest_slimes
		slimes = sorted(slimes)[::-1]
		s = sorted(s)[::-1]
	print('Yes')
main()


import sys

def main():
	(N, *S) = map(int, open(0).read().split())
	S = sorted(S)
	g = [S.pop(-1)]
	for gen in range(N):
		tmp = []
		for p in g[:2 ** gen]:
			while S:
				s = S.pop(-1)
				if p > s:
					g.append(s)
					break
				else:
					tmp.append(s)
			else:
				print('No')
				return
		S.extend(tmp[::-1])
		g.sort(reverse=True)
	print('Yes')

def __starting_point():
	main()
__starting_point()


N = int(input())
N2 = 1 << N
S = sorted([int(x) for x in input().split()])
s = []
s.append(S[-1])
S[-1] = -1
flag = True
for i in range(N):
	p = sorted([x for x in s])
	Si = N2 - 1
	while len(p) > 0 and Si >= 0:
		if S[Si] == -1:
			Si -= 1
			continue
		if S[Si] < p[-1]:
			s.append(S[Si])
			del p[-1]
			S[Si] = -1
		Si -= 1
	if len(p) > 0:
		flag = False
print('Yes' if flag else 'No')


def main():
	INF = float('inf')
	(N, *S) = list(map(int, open(0).read().split()))
	M = len(S)
	S.sort(reverse=True)
	Q = [S[0]]
	S[0] = INF
	for _ in range(N):
		Q.sort()
		T = Q[:]
		cur = 1
		while Q:
			p = Q.pop()
			while S[cur] >= p:
				cur += 1
				if cur == M:
					print('No')
					return
			T.append(S[cur])
			S[cur] = INF
		Q = T
	print('Yes')
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 main():
	n = I()
	a = sorted(LI())
	q = [a[-1]]
	a = a[:-1][::-1]
	for i in range(n):
		nq = []
		qi = 0
		na = []
		for ai in range(len(a)):
			c = a[ai]
			if q[qi] > c:
				nq.append(c)
				qi += 1
				if qi == len(q):
					na += a[ai + 1:]
					break
			else:
				na.append(c)
		if qi < len(q):
			return 'No'
		a = na
		q = sorted(q + nq, reverse=True)
	return 'Yes'
print(main())


N = int(input())
S = list(map(int, input().split()))
INF = 10 ** 10
S.sort()
parents = [S[-1]]
S[-1] = INF
from_here = 1
for _ in range(N):
	checking = from_here
	first = True
	parents.sort(reverse=True)
	for i in parents[:]:
		while True:
			if S[-checking] < i and first:
				parents.append(S[-checking])
				S[-checking] = INF
				from_here = checking + 1
				break
			elif S[-checking] < i:
				parents.append(S[-checking])
				S[-checking] = INF
				break
			else:
				checking += 1
				first = False
			if checking == 2 ** N + 1:
				print('No')
				return
else:
	print('Yes')


N = int(input())
S = list(map(int, input().split()))
S.sort()
p = [S[-1]]
r = S[:-1]
for i in range(N):
	nr = []
	for p_ in p[::-1]:
		while r:
			nr.append(r.pop())
			if nr[-1] < p_:
				p.append(nr.pop(-1))
				break
	p.sort()
	r += nr[::-1]
print('Yes' if len(r) == 0 else 'No')


import sys

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

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 INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
A.sort(reverse=1)
cur = [A[0]]
A[0] = -1
for _ in range(N):
	cur.sort(reverse=1)
	nxt = cur[:]
	j = 0
	for (i, a) in enumerate(A):
		if a == -1:
			continue
		if a < cur[j]:
			nxt.append(a)
			A[i] = -1
			j += 1
			if j == len(cur):
				break
	else:
		No()
		return
	cur = nxt[:]
Yes()


N = int(input())
A = sorted((int(x) for x in input().split()))
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
	next_parent = []
	next_rest = []
	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
				continue
	parent += next_parent
	parent.sort()
	rest = rest + next_rest[::-1]
bl = len(parent) == 2 ** N
answer = 'Yes' if bl else 'No'
print(answer)


import sys
input = sys.stdin.readline
n = int(input())
S = sorted(map(int, input().split()), reverse=True)
L = [S[0]]
used = [False] * (1 << n)
used[0] = True
for i in range(n):
	L.sort(reverse=True)
	idx = 0
	for (j, s) in enumerate(S):
		if used[j]:
			continue
		if L[idx] > s:
			L.append(s)
			used[j] = True
			idx += 1
			if idx == 1 << i:
				break
	else:
		print('No')
		return
print('Yes')


N = int(input())
M = 2 ** N
A = list(map(int, input().split()))
A.sort(reverse=True)
ar = [A[0]]
A[0] = -1
for _ in range(N):
	ar.sort(reverse=True)
	br = []
	i = 0
	while i < M and len(br) < len(ar):
		if A[i] >= 0:
			if ar[len(br)] > A[i]:
				br.append(A[i])
				A[i] = -1
		i += 1
	if len(br) < len(ar):
		print('No')
		return
	ar += br
print('Yes')


import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor
import numpy as np
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(2147483647)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))

def solve():
	counts = Counter(S)
	nums = list(sorted(list(counts.keys()), reverse=True))
	if counts[nums[0]] > 1:
		return False
	trees = [-i for i in range(1, N + 1)]
	heapq.heapify(trees)
	for n in nums[1:]:
		cnt = counts[n]
		if cnt > len(trees):
			return False
		uses = []
		for _ in range(cnt):
			t = -heapq.heappop(trees)
			uses.append(t)
		for t in uses:
			for i in range(1, t):
				heapq.heappush(trees, -i)
	return True
if solve():
	print('Yes')
else:
	print('No')


from collections import Counter
N = int(input())
(*S,) = map(int, input().split())
C = Counter(S)
memo = [[-1] * (N + 1) for i in range(N + 1)]

def comb(n, k):
	if memo[n][k] != -1:
		return memo[n][k]
	if k == 0 or n == k:
		return 1
	memo[n][k] = r = comb(n - 1, k) + comb(n - 1, k - 1)
	return r
(*CS,) = C.items()
CS.sort(reverse=1)
S = [0]
for (k, v) in CS:
	S.append(S[-1] + v)
T = [0]
for i in range(N + 1):
	T.append(T[-1] + comb(N, i))
ok = 1
if len(S) < len(T):
	ok = 0
else:
	ok = all((a <= b for (a, b) in zip(S, T))) and S[-2] >= 2 ** (N - 1)
print('Yes' if ok else 'No')


from collections import deque

def solve():
	N = int(input())
	Ss = list(map(int, input().split()))
	Ss.sort(reverse=True)
	Qs = [deque() for _ in range(N + 1)]
	Qs[0].append(10 ** 10)
	for S in Ss:
		for day in range(N + 1):
			if not Qs[day]:
				continue
			if Qs[day][0] > S:
				Qs[day].popleft()
				for d in range(day + 1, N + 1):
					Qs[d].append(S)
				break
		else:
			return False
	return True
if solve():
	print('Yes')
else:
	print('No')


import sys
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
ns = lambda : stdin.readline().rstrip()
n = ni()
a = na()
a.sort(reverse=True)
done = [False] * (1 << n)
b = [a[0]]
done[0] = True
for d in range(n):
	j = 0
	for i in range(1 << d):
		while j < 1 << n and (done[j] or b[i] <= a[j]):
			j += 1
		if j == 1 << n:
			print('No')
			return
		b.append(a[j])
		done[j] = True
	b.sort(reverse=True)
print('Yes')


N = int(input())
S = list(map(int, input().split()))
S.sort(reverse=True)
visit = [0] * 2 ** N
visit[0] = 1
used = [S[0]]
flag = 0
for i in range(N):
	add = used[::-1]
	k = 0
	for u in used:
		while k < 2 ** N:
			if visit[k] == 0 and S[k] < u:
				visit[k] = 1
				add.append(S[k])
				break
			k += 1
		if k >= 2 ** N:
			print('No')
			flag = 1
			break
	if flag == 1:
		break
	used = add[::-1]
	used.sort(reverse=True)
if flag == 0:
	print('Yes')


n = int(input())
a = list(map(int, input().split()))
a.sort()
parent = [a[-1]]
rest = a[:-1]
for _ in range(n):
	next_parent = []
	next_rest = []
	for i in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < i:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
				continue
	parent += next_parent
	parent.sort()
	next_rest.reverse()
	rest += next_rest
if len(parent) == 2 ** n:
	print('Yes')
else:
	print('No')


from heapq import heappush, heappop
from copy import deepcopy

def main():
	n = int(input())
	s = list(map(int, input().split()))
	left = []
	for e in s:
		heappush(left, -e)
	mx = heappop(left)
	made = []
	heappush(made, mx)
	for _ in range(n):
		made_prev = deepcopy(made)
		tmp = []
		while made_prev:
			made_val = heappop(made_prev)
			while left and left[0] <= made_val:
				pp = heappop(left)
				tmp.append(pp)
			if not left:
				print('No')
				return
			left_val = heappop(left)
			heappush(made, left_val)
		for e in tmp:
			heappush(left, e)
	print('Yes')

def __starting_point():
	main()
__starting_point()


N = int(input())
N2 = 2 ** N
S = list(map(int, input().split()))
S.sort(reverse=True)
slimes = [S[0]]
INF = S[0] + 1
S[0] = INF
num = 1
min_idx = 1
for i in range(N):
	slimes.sort()
	n = num
	idx = min_idx
	is_continuous = True
	while n and idx <= N2 - 1:
		if S[idx] < slimes[n - 1]:
			slimes.append(S[idx])
			S[idx] = INF
			idx += 1
			n -= 1
			min_idx += is_continuous
		else:
			if S[idx] < INF:
				is_continuous = False
			idx += 1
			min_idx += is_continuous
	if n:
		print('No')
		return
	num *= 2
print('Yes')


from collections import Counter
from heapq import heapify, heappush, heappop

def solve():
	N = int(input())
	Ss = list(map(int, input().split()))
	cnt = Counter(Ss)
	PQ = [-N]
	for key in sorted(list(cnt.keys()), reverse=True):
		num = cnt[key]
		if len(PQ) < num:
			return False
		depths = []
		for _ in range(num):
			depths.append(-heappop(PQ))
		for depth in depths:
			for d in range(depth):
				heappush(PQ, -d)
	return True
if solve():
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import deque
N = int(input())
A = sorted((int(x) for x in input().split()))
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
	next_parent = []
	next_rest = []
	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
				continue
	parent += next_parent
	parent.sort()
	rest = rest + next_rest[::-1]
bl = len(parent) == 2 ** N
answer = 'Yes' if bl else 'No'
print(answer)


from sys import stderr, stdin
input = stdin.readline
from collections import defaultdict
from sys import stderr

def debug(var, name='hoge'):
	print(name + ':' + str(type(var)) + ' = ' + repr(var), file=stderr)
	return

def main():
	N = int(input())
	S = [int(a) for a in input().split()]
	S = sorted(S)
	exist = [S.pop()]
	debug(S)
	debug(exist)
	for i in range(N):
		next_exist = []
		next_s = []
		for p in exist[::-1]:
			while S:
				x = S.pop()
				if x < p:
					next_exist.append(x)
					break
				else:
					next_s.append(x)
		exist += next_exist
		exist.sort()
		S += next_s[::-1]
	if len(exist) == 2 ** N:
		print('Yes')
		return
	else:
		print('No')
		return

def __starting_point():
	main()
__starting_point()


N = int(input())
a = list(map(int, input().split(' ')))
a.sort()
fathers = [a.pop()]
for _ in range(N):
	sons = list()
	b = list()
	for father in fathers:
		while a:
			x = a.pop()
			if father > x:
				sons.append(x)
				break
			else:
				b.append(x)
	a = a + b[::-1]
	fathers.extend(sons)
	fathers.sort(reverse=True)
if len(fathers) == 2 ** N:
	print('Yes')
else:
	print('No')


N = int(input())
S = sorted([int(a) for a in input().split()])
X = [1] + [0] * N

def popX(i0):
	for i in range(i0, N + 1):
		if X[i]:
			X[i] -= 1
			return i
	return N + 1

def addX():
	for l in L:
		for i in range(l + 1, N + 1):
			X[i] += 1
while S:
	a = S.pop()
	c = 1
	L = [popX(0)]
	while S and S[-1] == a:
		S.pop()
		c += 1
		L.append(popX(L[-1]))
	if L[-1] > N:
		print('No')
		break
	addX()
else:
	print('Yes')


from collections import deque
N = int(input())
S = list(map(int, input().split()))
S.sort()
used = [S.pop()]
for _ in range(N):
	(l, r) = (0, len(used))
	reuse = deque()
	for i in range(len(S)):
		v = S.pop()
		if v < used[l]:
			used.append(v)
			l += 1
		else:
			reuse.appendleft(v)
		if l == r:
			break
	else:
		print('No')
		break
	S.extend(reuse)
	used.sort(reverse=True)
else:
	print('Yes')


from heapq import heapify, heappush, heappop

def solve():
	N = int(input())
	Ss = list(map(int, input().split()))
	Ss.sort(reverse=True)
	pow2s = [2 ** i for i in range(N)]
	PQs = [[-Ss[0]] for _ in range(N)]
	nums = [0] * N
	tm0 = 0
	for S in Ss[1:]:
		for tm in range(tm0, N):
			if nums[tm] >= pow2s[tm]:
				tm0 = tm
			elif -PQs[tm][0] > S:
				heappop(PQs[tm])
				nums[tm] += 1
				for i in range(tm + 1, N):
					heappush(PQs[i], -S)
				break
		else:
			return False
	return True
if solve():
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
import heapq as hp
from collections import Counter

def main():
	N = int(input())
	A = list(map(int, input().split()))
	graph = [[] for _ in range(1 << N)]
	for l in range(N):
		for n in range(1 << l):
			graph[n].append(n + (1 << l))
	C = Counter(A)
	Keys = sorted(C.keys(), reverse=True)
	q = [(-len(graph[0]), 0)]
	for key in Keys:
		num = C[key]
		if num > len(q):
			return False
		use = []
		for _ in range(num):
			(_, p) = hp.heappop(q)
			use.append(p)
		for p in use:
			for np in graph[p]:
				hp.heappush(q, (-len(graph[np]), np))
	return True

def __starting_point():
	print('Yes' if main() else 'No')
__starting_point()


def solve_f(n, s_list):
	res = 'Yes'
	stage = 0
	s_list_s = sorted(s_list)
	length = len(s_list_s)
	resolved = [0] * length
	resolved[-1] = 1
	for i in range(n):
		parents = [s_list_s[k] for k in range(length) if resolved[k]]
		for j in range(length - 1, -1, -1):
			if parents[-1] > s_list_s[j] and resolved[j] == 0:
				resolved[j] = 1
				_ = parents.pop()
			if len(parents) == 0:
				break
		if len(parents) > 0:
			res = 'No'
			break
	return res

def main():
	n = int(input())
	s_list = list(map(int, input().split()))
	print(solve_f(n, s_list))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
big = [a[-1]]
rest = a[:-1]
for i in range(n):
	not_yet = []
	count = 0
	for b in big:
		if count == 2 ** i:
			break
		while rest:
			r = rest.pop()
			if r < b:
				big.append(r)
				count += 1
				break
			not_yet.append(r)
	big.sort(reverse=True)
	rest += not_yet[::-1]
print('Yes' if len(rest) == 0 else 'No')


import math

def cmb(n, r):
	return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
n = int(input())
a = list(map(int, input().split()))
a.sort()
ls = [0]
cnt = 0
for i in range(1, 2 ** n):
	if a[i] > a[i - 1]:
		cnt += 1
	ls.append(cnt)
lmt = []
for i in range(n + 1):
	lmt.extend([i] * cmb(n, i))
bias = ls[-1] - lmt[-1]
jdg = 0
ulmt = 0
for i in range(n):
	jdg += ls.count(i)
	ulmt += 2 ** (n - i - 1)
	if jdg > ulmt:
		print('No')
		return
for (x, l) in zip(ls, lmt):
	if x - l > bias:
		print('No')
		break
else:
	print('Yes')


def main():
	inf = 10 ** 9 + 5
	n = int(input())
	n2 = 2 ** n
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	pp = [s[0]]
	s[0] = inf
	for _ in range(n):
		pp.sort()
		i = 1
		np = pp[:]
		while pp:
			p = pp.pop()
			while 1:
				if s[i] < p:
					np.append(s[i])
					s[i] = inf
					break
				else:
					i += 1
				if i == n2:
					print('No')
					return
		pp = np
	print('Yes')
main()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	visited = [False] * 2 ** n
	visited[0] = 0
	now = [a[0]]
	for i in range(n):
		new = []
		now2 = 0
		for (j, i) in enumerate(a):
			if visited[j]:
				continue
			if now[now2] > i:
				now2 += 1
				new += [i]
				visited[j] = True
				if now2 == len(now):
					now += new
					now.sort(reverse=True)
					break
		else:
			print('No')
			return
	print('Yes')
main()


N = int(input())
S = list(map(int, input().split()))
S.sort(reverse=True)
Closed = [False] * (1 << N)
Closed[0] = True
for j in range(N):
	num = 1 << j
	cnt_all = 0
	cnt = 0
	cnt_ = 0
	s_old = -1
	for (i, s) in enumerate(S):
		if s_old != s:
			cnt += cnt_
			cnt_ = 0
		c = Closed[i]
		if c:
			cnt_ += 1
		elif cnt > 0:
			Closed[i] = True
			cnt -= 1
			cnt_all += 1
			if cnt_all == num:
				break
		s_old = s
	else:
		print('No')
		return
print('Yes')


def f_f():
	(n, *s) = list(map(int, open(0).read().split()))
	s.sort()
	(ps, next_ps, cs) = ([s.pop()], [], [])
	for _ in range(n):
		for p in ps:
			while s:
				c = s.pop()
				if p > c:
					next_ps.append(c)
					break
				else:
					cs.append(c)
		(s, ps, next_ps, cs) = (s + cs[::-1], sorted(ps + next_ps, reverse=True), [], [])
	print('No' if s else 'Yes')

def __starting_point():
	f_f()
__starting_point()


from collections import Counter
from heapq import heappop, heappush

def solve(n, sss):
	ccc = Counter(sss)
	keys = sorted(list(ccc.keys()), reverse=True)
	if ccc[keys[0]] != 1:
		return False
	q = [(1, keys[0])]
	for k in keys[1:]:
		nq = []
		for _ in range(ccc[k]):
			try:
				(r, s) = heappop(q)
			except IndexError:
				return False
			if r < n:
				nq.append((r + 1, k))
				heappush(q, (r + 1, s))
		for item in nq:
			heappush(q, item)
	return True
n = int(input())
sss = list(map(int, input().split()))
print('Yes' if solve(n, sss) else 'No')


from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)
key_num = len(cnt.keys())
rank = [0] * key_num
keys = list(cnt.keys())
keys.sort(reverse=True)
for (i, key) in enumerate(keys):
	rank[i] = cnt[key]
cur = [0] * key_num
cur[0] = 1
for i in range(n):
	tmp = cur[:]
	free = 0
	for j in range(key_num):
		if rank[j] > cur[j] and free > 0:
			if cur[j] + free > rank[j]:
				free -= rank[j] - cur[j]
				cur[j] = rank[j]
			else:
				cur[j] += free
				free = 0
		free += tmp[j]
if sum(cur) == 2 ** n:
	print('Yes')
else:
	print('No')