from heapq import heapify, heappush, heappop



def solve():

    N = int(eval(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

            else:

                if -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')

from collections import deque



def solve():

    N = int(eval(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')

from heapq import heapify, heappush, heappop


def solve():
    N = int(eval(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
            else:
                if -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")

from collections import deque


def solve():
    N = int(eval(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")

-from heapq import heapify, heappush, heappop +from collections import deque -    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 -            else: -                if -PQs[tm][0] > S: -                    heappop(PQs[tm]) -                    nums[tm] += 1 -                    for i in range(tm + 1, N): -                        heappush(PQs[i], -S) -                    break +    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