//Coded by not_surrender
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define MAXN 300003
#define MOD 1000000007
#define oo (1<<20)
#define mid ((a+b)/2)
#define pb push_back
#define sz size()
#define fastCpp() ios_base::sync_with_stdio( false ), cin.tie( NULL ), cout.tie( NULL )

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;

int N, A[MAXN], ans, best[2];
 
int main(){

    #ifndef ONLINE_JUDGE
		//~ freopen( "a.txt", "r", stdin );
        //~ freopen( "fibsubseq.in", "r", stdin );
        //~ freopen( "fibsubseq.out", "w", stdout );
    #endif // ONLINE_JUDGE
    
    fastCpp();
    
    scanf( "%d", &N );
    
    N = 1<<N;
    
    for ( int i = 0; i < N; ++i )
		scanf( "%d", &A[i] );
	
	vi now;
	for ( int i = 1; i < N; ++i ){
		now.clear();
		best[0] = best[1] = 0;
		for ( int j = 1; j <= i; j <<= 1 )
			if ( j&i )
				now.pb( j );
		for ( int mask = 0, lim = 1<<((int)now.sz), pos; mask < lim; ++mask ){
			pos = 0;
			for ( int j = 0; (1<<j) < lim; ++j )
				pos += now[j]*((mask&(1<<j)) > 0);
			if ( A[pos] > best[0] )
				best[1] = best[0], best[0] = A[pos];
			else
				if ( A[pos] > best[1] )
					best[1] = A[pos];
		}
		ans = max( ans, best[0]+best[1] );
		printf( "%d\n", ans );
	}
	
return 0;
}
