import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

immutable long inf = 10L^^15;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto m = 1<<n;
    auto dp = new int[][](m, 2);
    foreach (i ; 0 .. m) {
        dp[i][0] = i;
        dp[i][1] = -1;
    }

    debug {
        writeln(dp);
    }

    foreach (s ; 0 .. m) {
        foreach (j ; 0 .. 20) {
            if ((s >> j) & 1) {
                int sb = s ^ (1 << j);
                foreach (r ; 0 .. 2) {
                    if (dp[sb][r] == -1) continue;
                    if (a[dp[sb][r]] > a[dp[s][0]]) {
                        dp[s][1] = dp[s][0];
                        dp[s][0] = dp[sb][r];
                    }
                    else if ((dp[s][1] == -1 || a[dp[sb][r]] > a[dp[s][1]]) && dp[s][0] != dp[sb][r]) {
                        dp[s][1] = dp[sb][r];
                    }
                }
            }
        }
    }

    debug {
        writeln(dp);
    }

    auto ans = new long[](m + 1);

    foreach (i ; 1 .. m) {
        ans[i] = max(ans[i-1], a[dp[i][0]]+ a[dp[i][1]]);
        writeln(ans[i]);
    }

}




































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
