#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int f1[2000005],f2[2000005],a[2000005],n,m,s;
int main()
{
	scanf("%d",&n);
	m=(1<<n);
	for (int i=0;i<m;i++)
		scanf("%d",&a[i]);
	for (int i=0;i<m;i++)
		for (int j=i;j>=0;j=(j-1)&i)
		{
			if (a[j]>f1[i]) f2[i]=f1[i],f1[i]=a[j];
			else if (a[j]>f2[i]) f2[i]=a[j];
			if (j==0) break;
		}
	for (int i=1;i<m;i++)
	{
		s=max(s,f1[i]+f2[i]);
		printf("%d\n",s);
	}
	return 0;
}