// Original C++ solution (slower):
/*alurquiza*/

//

#include <bits/stdc++.h>



using namespace std;



const int SIZE = 18,SIZE2 = 1 << SIZE;

int DP[SIZE2];

int MAX[SIZE2][4];

vector<int> V(SIZE2);



bool comp(const int &a,const int &b){

    if(a == -1)

        return false;

    if(b == -1)

        return true;



    if(V[a] >= V[b])

        return true;

    return false;

}



void join(int mask,int smask){

    MAX[mask][2] = MAX[smask][0];

    MAX[mask][3] = MAX[smask][1];



    int N = 4;

    stable_sort(MAX[mask],MAX[mask] + N);

    N = unique(MAX[mask],MAX[mask] + N) - MAX[mask];



    stable_sort(MAX[mask],MAX[mask] + N,comp);

}



int main()

{

//    ios_base::sync_with_stdio(0);

//    cin.tie(0); cout.tie(0);



//    freopen(".in","r",stdin);

//    freopen("F.out","w",stdout);



    int N;

    cin >> N;



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

        cin >> V[i];



    for(int mask = 0;mask < (1 << N);mask++){

        MAX[mask][0] = mask;

        MAX[mask][1] = -1;



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

            if((1 << i) & mask){

                int nmask = mask ^ (1 << i);

                join(mask,nmask);

            }

        }

        if(MAX[mask][1] != -1)

            DP[mask] = V[MAX[mask][1]];

        DP[mask] += V[MAX[mask][0]];

    }



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

        DP[i] = max(DP[i],DP[i - 1]);

        cout << DP[i] << '\n';

    }



    return 0;

}


// Optimized solution to the same problem (faster):


# include <bits/stdc++.h>

# define A first

# define B second

# define PII pair<int,int>

using namespace std;

const int maxn = 1<<18;

int a[maxn+3];

PII imax[maxn];

void fun(int x, PII &y)

{

    if(x == y.A || x == y.B) return;

    if(a[x] > a[y.A]) y.B = y.A,y.A = x;

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

}

int main()

{

    int N, n, ans=0;

    scanf("%d",&n);

    N = 1<<n;

    a[N] = 0;

    for(int i=0; i<N; ++i) scanf("%d",&a[i]), imax[i].A=i, imax[i].B=N;

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

    {

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

        {

            if(i&(1<<j))

            {

                int k=i^(1<<j);

                fun(imax[k].A, imax[i]);

                fun(imax[k].B, imax[i]);

            }

        }

    }

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

    {

        ans = max(ans, a[imax[i].A]+a[imax[i].B]);

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

    }

    return 0;

}


// 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;

	}