// Original C++ solution (slower):
#include<cstdio>

#include<algorithm>

#include<iostream>

using namespace std;

typedef long long ll;

struct ee{

	int fi,se;

}p[524290];

int n,a[524290],N,ans;

void f(int x,int y)

{

	if(x==p[y].fi||x==p[y].se) return;

	if(a[x]>a[p[y].fi]) p[y].se=p[y].fi,p[y].fi=x;

	else if(a[x]>a[p[y].se]) p[y].se=x;

}

int main()

{

	scanf("%d",&n);

	N=1<<n;

	for(int i=0;i<N;i++) scanf("%d",&a[i]),p[i].fi=i,p[i].se=N;

	for(int i=1,j,ls,now;i<N;i++)

	{

		ls=i;

		j=(i-1)&i;

		for(;ls;)

		{

				int k=i^(ls-j);

				f(p[k].fi,i);

				f(p[k].se,i);

				ls=j;

				j=(j-1)&j;

		}

	}

	for(int i=1;i<N;i++)

	{

		ans=max(ans,a[p[i].fi]+a[p[i].se]);

		printf("%d\n",ans);

	}

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cctype>

#include <algorithm>

#define MAXN 1100005

using namespace std;

int a[MAXN];

int fst[MAXN]={0};

int sec[MAXN]={0};

int tmp[25];

int temp[5];

int f[MAXN];

int read(void);

void write(int x);

int main(void){

    int len,n;

    len=read();

    n=1<<len;

    for (int i=0;i<n;i++)

        fst[i]=read();

    for (int l=0;l<len;l++){

        int tpow=1<<l;

        for (int i=1;i<n;i++){

            if (i&tpow){

                //Use i^tpow;

                int tfore=i^tpow;

                temp[0]=fst[i],temp[1]=sec[i];

                temp[2]=fst[tfore],temp[3]=sec[tfore];

                sort(temp,temp+4);

                fst[i]=temp[3],sec[i]=temp[2];

            }

        }

    }

    f[0]=fst[0];

    for (int i=1;i<n;i++)

        f[i]=max(f[i-1],fst[i]+sec[i]);

    for (int i=1;i<n;i++)

        write(f[i]);

    return 0;

}



int read(void){

    int ans=0;

    char ch;

    do {

        ch=getchar();

    } while (!isdigit(ch));

    while (isdigit(ch)){

        ans=ans*10+(ch-'0');

        ch=getchar();

    }

    return ans;

}



void write(int x){

    int lg=0;

    if (!x){

        putchar('0');

        return;

    }

    while (x){

        tmp[lg++]=x%10;

        x/=10;

    }

    for (int i=lg-1;i>=0;i--)

        putchar(tmp[i]+'0');

    putchar('\n');

}

// Fastest known solution for this problem:
	#include <bits/stdc++.h>

	#define mx 300005

	using namespace std;



	int a[mx], n;

	vector<vector<bool> > vis(mx, vector<bool> (20, false));

	vector<vector<pair<int,int> > > memo(mx, vector<pair<int, int> > (20, {0, 0}));



	void dp(int num, int pos) {

		if(pos == 0) {

			memo[num][0].first = a[num];

			vis[num][0] = true;

			return;

		}

		if(vis[num][pos]) return;

 		vector<int> cons;

		dp(num, pos-1);

		cons.push_back(memo[num][pos-1].first);

		cons.push_back(memo[num][pos-1].second);

		if(num & (1<<(pos-1))) {

			dp(num ^ (1<<(pos-1)), pos-1);

			cons.push_back(memo[num ^ (1<<(pos-1))][pos-1].first);

			cons.push_back(memo[num ^ (1<<(pos-1))][pos-1].second);

		}

		sort(cons.begin(), cons.end(), greater<int>());

		memo[num][pos].first = cons[0];

		memo[num][pos].second = cons[1];

		vis[num][pos] = true;

	}



	int main() {

		ios_base::sync_with_stdio(false);

	    cin.tie(NULL);

	    cout.tie(NULL);



		cin >> n;

		for(int i = 0; i < (1<<n); ++i) {

			cin >> a[i];

			

		}

		for(int i = (1<<n) - 1; i >= 0; --i) {

			if(!vis[i][n]) {

				dp(i, n);

			}

		}

		int mxv = 0;

		for(int i = 1; i < 1<<n; ++i) {

			mxv = max(memo[i][n].first + memo[i][n].second, mxv);

			cout << mxv << "\n";	

		}

		return 0;

	}