```
include[HTML_REMOVED]
using namespace std;
const int N=25;
int l[N],r[N],v[N],h[N];
int n,idx,root;
int q[N],hh,tt;
int max_k;
int height(int u)
{
return h[l[u]]-h[r[u]];
}
void update(int u)
{
h[u]=max(h[l[u]],h[r[u]])+1;
}
void R(int &u)
{
int p=l[u];
l[u]=r[p],r[p]=u;
update(u),update(p);
u=p;
}
void L(int &u)
{
int p=r[u];
r[u]=l[p],l[p]=u;
update(u),update(p);
u=p;
}
void insert(int &u,int x)
{
if(!u) u=++idx,v[u]=x;
else if(x[HTML_REMOVED]max_k) max_k=k;
check(l[u],2k);
check(r[u],2k+1);
}
int main()
{
cin>>n;
for(int i=0;i[HTML_REMOVED]>x;
insert(root,x);
}
bfs();
check(root,1);
if(max_k==n) cout<<endl<<”YES”;
else cout<<endl<<”NO”;
return 0;
}```