#include <bits/stdc++.h>
using namespace std;

int n, a[1<<18], x[1<<18], y[1<<18];

void update(int k, int p) {
    if (p == x[k] or p == y[k]) return;
    if (a[p] > a[x[k]]) y[k] = x[k], x[k] = p;
    else if (a[p] > a[y[k]]) y[k] = p;
}

int main() {
    cin >> n;
    for (int i=0; i<(1<<n); i++) cin >> a[i], x[i] = 1<<n, y[i] = 1<<n;

    x[0] = 0;

    int mx = 0;
    for (int i=1; i<(1<<n); i++) {
        update(i, i);
        for (int j=0; j<n; j++) if ((i>>j)&1) update(i, x[i^(1<<j)]), update(i, y[i^(1<<j)]);
        mx = max(mx, a[x[i]] + a[y[i]]);

        cout << mx << '\n';
    }
}