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 rbt = new RedBlackTree!(int, "a > b", true);
    foreach (a; A) rbt.insert(a);

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

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

    writeln("Yes");
}