#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int q[MAXN],cnt[MAXN],a[MAXN],b[MAXN],c[MAXN];
vector<int> e[MAXN];
struct Segment_Tree
{
	struct treenode{int l,r,sum,q; } tree[MAXN<<2];
	void up(int x)
	{  
	    tree[x].sum=tree[x<<1].sum+tree[x<<1|1].sum;  
	    if (tree[x<<1|1].sum>0) tree[x].q=tree[x<<1|1].q;
	    else if (tree[x<<1].sum>0) tree[x].q=tree[x<<1].q;
	    else tree[x].q=-1;
	}
	void build(int x,int l,int r)
	{
		if ((tree[x].l=l)==(tree[x].r=r))
		{
			tree[x].sum=c[l];
			tree[x].q=l;
			return;
		}
		int mid=(l+r)>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		up(x);
	}
	void change(int x,int y,int z)
	{
		if (tree[x].l==tree[x].r)
		{
			tree[x].sum+=z;
			if (tree[x].sum==0) tree[x].q=-1;
			return;
		}
		int mid=(tree[x].l+tree[x].r)>>1;
		if (y<=mid) change(x<<1,y,z);
		else change(x<<1|1,y,z);
		up(x);
	}
	int query(int x,int l,int r)
	{
		if (tree[x].l>=l&&tree[x].r<=r) return tree[x].q;
		int mid=(tree[x].l+tree[x].r)>>1;
		if (r<=mid) return query(x<<1,l,r);
		else if (l>mid) return query(x<<1|1,l,r);
		else return max(query(x<<1,l,mid),query(x<<1|1,mid+1,r));
	}
	void print()
	{
		for (int i=1;i<=10;i++) 
		    cout<<tree[i].l<<" "<<tree[i].r<<":"<<tree[i].q<<" "<<tree[i].sum<<endl;
	}
} segment;
int main()
{
    int k=read(),n=1;
    for (int i=1;i<=k;i++) n*=2;
    for (int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) 
    {
        if (a[i]==a[i-1]) b[i]=b[i-1];
        else b[i]=b[i-1]+1;
        e[b[i]].push_back(i);
        c[b[i]]++;
    }
    
    int num=1; 
	q[1]=n;
    segment.build(1,1,b[n]);
    
//    segment.print();
    
	segment.change(1,b[n],-1);
	
//	cout<<b[n]<<endl;
//    segment.print();
    for (int i=1;i<=k;i++)
    {
    	int p=num;
    	for (int j=1;j<=p;j++)
    	{
    		if (b[q[j]]==1) { puts("No"); return 0; }
    		
    		int t=segment.query(1,1,b[q[j]]-1);
    		
//    		cout<<t<<endl;
//    		segment.print();
    		
    		if (t==-1) { puts("No"); return 0;}
    		q[++num]=e[t][cnt[t]]; cnt[t]++;
    		segment.change(1,t,-1);
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 43776