import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto pq1 = new BinaryHeap!(Array!int, "a < b");
    auto pq2 = new BinaryHeap!(Array!int, "a < b");
    foreach (a; A) pq1.insert(a);

    auto S = [pq1.front];
    pq1.removeFront;

    foreach (i; 0..N) {
        S.sort!"a > b";
        int ol = S.length.to!int;
        for (int j = 0; j < ol && !pq1.empty; ) {
            if (S[j] > pq1.front) {
                S ~= pq1.front;
                pq1.removeFront;
                j += 1;
            } else {
                pq2.insert(pq1.front);
                pq1.removeFront;
            }
        }
        if (S.length != (1 << (i + 1))) {
            writeln("No");
            return;
        }
        while (!pq2.empty) {
            pq1.insert(pq2.front);
            pq2.removeFront;
        }
    }

    writeln("Yes");
}