#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int a[262144],rev[262144],lw[262144],hi[262144],val[262144];
struct pr{
	int x,y;
	pr(int a=0,int b=0){x=a;y=b;}
};
bool operator<(pr a,pr b){return a.x==b.x?a.y>b.y:a.x>b.x;}
priority_queue<pr>q;
vector<pr>e[262144];
int main(){
	int n,N,i,j;
	scanf("%d",&n);
	N=1<<n;
	for(i=0;i<N;i++)rev[i]=(rev[i>>1]>>1)|((i&1)<<(n-1));
	for(i=0;i<N;i++){
		scanf("%d",a+i);
		a[i]--;
	}
	for(i=N-1;i>=0;i--){
		hi[i]=~a[i]?a[i]:N-1;
		for(j=0;j<n;j++){
			if(~i>>j&1)hi[i]=min(hi[i],hi[i|(1<<j)]);
		}
	}
	for(i=0;i<N;i++){
		lw[i]=~a[i]?a[i]:0;
		for(j=0;j<n;j++){
			if(i>>j&1)lw[i]=max(lw[i],lw[i^(1<<j)]);
		}
	}
	for(i=0;i<N;i++){
		if(lw[i]>hi[i]){
			puts("NO");
			return 0;
		}
		e[lw[i]].push_back(pr(hi[i],i));
	}
	for(i=0;i<N;i++){
		for(pr t:e[i])q.push(t);
		if(q.empty()||q.top().x<i){
			puts("NO");
			return 0;
		}
		val[q.top().y]=i;
		q.pop();
	}
	puts("YES");
	for(i=0;i<N;i++)printf("%d ",val[rev[i]]+1);
}