#include<bits/stdc++.h>
using namespace std;
int a[1000010],n,r,s1,s2;
int main(){
	scanf("%d",&r);
	for(int i=0;i<(1<<r);i++)
		scanf("%d",&a[i]);
	for(int i=1;i<(1<<n);i++){
		s1=a[i],s2=0;
		for(int j=i;j;j=(j-1)&i){
			if(a[j]>s1){
				s2=s1;
				s1=a[j];
			}
			else if(a[j]>s2)
				s2=a[j];
		}
		ans=max(ans,s1+s2);
		printf("%d\n",ans);
	}
}