//============================================================================
// Name        : training.cpp
// Author      : CoNKeR The Red Squirrel
//============================================================================
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
	cin >> n;

	n = 1 << n;

	vector<int> A(n);
	for(int &x : A) { cin >> x; }

	vector<pair<int, int>> dp(n, {INT32_MIN, INT32_MIN});
	int sol = INT32_MIN;

	for(int i = 1; i < n; ++i) {
        set<int> choices;
		for(int mask = 1; mask <= i; mask <<= 1) {
			if(i & mask) {
				int sm = i ^ mask;
				choices.insert(dp[sm].first);
				choices.insert(dp[sm].second);
			}
		}

		int first = i, second = 0;
		for(int j : choices) {
            if(A[j] > A[first]) { second = first, first = j; }
            else if(A[j] > A[second]) { second = j; }
		}

		sol = max(sol, A[first] + A[second]);
		dp[i] = {first, second};

		cout << sol << "\n";
	}

    return 0;
}
