import std.stdio, std.conv, std.string, std.array, std.algorithm;

void main(){
  int n = readln.chomp.to!int;
  int[] as = readln.chomp.split.to!(int[]);

  as.sort!"a>b"();
  stderr.writeln("as:", as);

  int j = 0;
  for(long m = 1; m < (1L << n); m *= 2){
    foreach(i; 0 .. m){
      if(as[i] <= as[i + m]){
        while(j < as.length - 1 && as[i] <= as[j]) j ++;
        if(j >= as.length){
          "No".writeln;
          return;
        }
        int z = as[j]; as[j] = as[i + m]; as[i + m] = z;
      }
      stderr.writeln("as:", as, " i:", i, " m:", m, " j:", j);
      j ++;
    }
  }
  "Yes".writeln;
  stderr.writeln("as:", as);
}