#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
typedef long long ll;
const int N=500005;
int m,n,a[N],mx[N],ans[N];
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d",&m),n=(1<<m);
	int i,j,x,y;
	for (i=0;i<n;i++) scanf ("%d",&a[i]);
	for (i=1;i<n;i++)
	{
		for (j=(i-1)&i,x=max(a[i],a[0]),y=min(a[i],a[0]);j;j=(j-1)&i)
		{
			if (a[j]>x) y=x,x=a[j];
			else if (a[j]>y) y=a[j];
		}
		ans[i]=x+y;
	}
	for (i=2;i<n;i++) ans[i]=max(ans[i],ans[i-1]);
	for (i=1;i<n;i++) printf ("%d\n",ans[i]);
	return 0;
}
