#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    vector<long long> data(1 << n);
    for(int i = 0; i < (1 << n); ++i)
        cin >> data[i];

    long long best = 0;
    for(int msk = 1; msk < (1 << n); ++msk){
        for(int sub = msk; sub > 0; sub = msk & (sub - 1)){
            best = max(best, data[sub] + data[msk - sub]);
            if(msk != sub)
                best = max(best, data[msk] + data[msk - sub]);
        }
        cout << best << "\n";
    }

    return 0;
}//RUL0
