#include<bits/stdc++.h>
#define taskname "OrPlusMax"
#define int long long
using namespace std;
vector<int> a;
void update(int i, pair<int, int> &p)
{
    if (i == p.first || i == -1) return;
    if (p.first == -1 || a[i] > a[p.first])
    {
        swap(p.first, p.second);
        p.first = i;
    }
    else if (p.second == -1 || a[i] > a[p.second]) p.second = i;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    int n;  cin >> n;
    a.resize(1 << n);
    for (int &i : a) cin >> i;
    vector<pair<int, int>> v(1 << n, {-1, -1});
    vector<int> ans(1 << n, 0);
    for (int i = 0; i < 1 << n; ++i)
    {
        update(i, v[i]);
        for (int j = 1; j <= n; ++j)
            if (((i >> (j - 1)) & 1) == 0)
            {
                int x = i ^ (1 << (j - 1));
                update(v[i].first, v[x]);
                update(v[i].second, v[x]);
            }
        if (i)
        {
            ans[i] = max(ans[i - 1], a[v[i].first] + a[v[i].second]);
            cout << ans[i] << '\n';
        }
    }
}
