import time



start = time.time()



n = int(eval(input()))

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



s.sort()

s.reverse()



flag = True

for i in range(n):

    a = s[0:2 ** i]

    b = s[2 ** i:2 ** (i + 1)]

    for j in range(len(a)):

        if b[j] >= a[j]:

            flag = False

            break

if flag:

    print('Yes')

    exit()



s.reverse()



a = []

a.append(s[-1])

s.pop(-1)

for i in range(n):

    for j in range(len(a)):

        for k in range(len(s)):

            if a[j]>s[-1-k]:

                a.append(s[-1-k])

                s.pop(-1-k)

                break

        if time.time() - start > 1.8:

            print('Yes')

            exit()

    if len(a)!=2**(i+1):

        print('No')

        exit()



print('Yes')



n = int(eval(input()))

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



s.sort()



a = [s[-1]]

b = s[:-1]



for i in range(n):

    a2 = []

    b2 = []

    for x in a:

        while b:

            y = b.pop()

            if x>y:

                a2.append(y)

                break

            else:

                b2.append(y)

    a = a + a2

    b = b + b2

    a.sort()

    a.reverse()

    b.sort()

    if len(a)!=2**(i+1):

        print('No')

        exit()

print('Yes')

import time

start = time.time()
n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
s.reverse()
flag = True
for i in range(n):
    a = s[0 : 2**i]
    b = s[2**i : 2 ** (i + 1)]
    for j in range(len(a)):
        if b[j] >= a[j]:
            flag = False
            break
if flag:
    print("Yes")
    exit()
s.reverse()
a = []
a.append(s[-1])
s.pop(-1)
for i in range(n):
    for j in range(len(a)):
        for k in range(len(s)):
            if a[j] > s[-1 - k]:
                a.append(s[-1 - k])
                s.pop(-1 - k)
                break
        if time.time() - start > 1.8:
            print("Yes")
            exit()
    if len(a) != 2 ** (i + 1):
        print("No")
        exit()
print("Yes")

n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
a = [s[-1]]
b = s[:-1]
for i in range(n):
    a2 = []
    b2 = []
    for x in a:
        while b:
            y = b.pop()
            if x > y:
                a2.append(y)
                break
            else:
                b2.append(y)
    a = a + a2
    b = b + b2
    a.sort()
    a.reverse()
    b.sort()
    if len(a) != 2 ** (i + 1):
        print("No")
        exit()
print("Yes")

-import time - -start = time.time() -s.reverse() -flag = True +a = [s[-1]] +b = s[:-1] -    a = s[0 : 2**i] -    b = s[2**i : 2 ** (i + 1)] -    for j in range(len(a)): -        if b[j] >= a[j]: -            flag = False -            break -if flag: -    print("Yes") -    exit() -s.reverse() -a = [] -a.append(s[-1]) -s.pop(-1) -for i in range(n): -    for j in range(len(a)): -        for k in range(len(s)): -            if a[j] > s[-1 - k]: -                a.append(s[-1 - k]) -                s.pop(-1 - k) +    a2 = [] +    b2 = [] +    for x in a: +        while b: +            y = b.pop() +            if x > y: +                a2.append(y) -        if time.time() - start > 1.8: -            print("Yes") -            exit() +            else: +                b2.append(y) +    a = a + a2 +    b = b + b2 +    a.sort() +    a.reverse() +    b.sort()