#include<bits/stdc++.h>

using namespace std;

#define X   first
#define Y   second

const int   N   = (1 << 18);

typedef pair<int,int>   ii;

ii  f[N];

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

    int n;  cin >> n;

    for(int i = 0 ; i < (1 << n) ; ++i)
        cin >> f[i].X;

    for(int i = 0 ; i < n ; ++i)
        for(int m = 0 ; m < (1 << n) ; ++m)
            if(m >> i & 1)  {
                f[m].Y = max(f[m].Y,f[m ^ (1 << i)].X);
                if (f[m].X < f[m].Y)
                    swap(f[m].X,f[m].Y);
            }

    int last = 0;

    for(int k = 1 ; k < (1 << n) ; ++k)   {
        int ans = last;
        ans = max(ans,f[k].X + f[k].Y);
        cout << ans << "\n";
        last = ans;
    }
}