#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int mx[1<<18], n, a[1<<18];
void get_ans (int l, int r) {
	int b[(r-l)/2];
	if(l+1 == r) return;
	int mid = l+r >> 1;
	get_ans(l, mid);
	for(int i = mid; i < r; ++i)
		mx[i] = max(mx[i], a[i] + a[i - (r - mid)]);
	for(int i = mid; i < r; ++i)
		b[i-mid] = a[i], a[i] = max(a[i], a[i - (r - mid)]);
	get_ans(mid, r);
	for(int i = mid; i < r; ++i)
		a[i] = b[i-mid];
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < 1<<n; ++i) {
		scanf("%d", &a[i]);
	}
	get_ans(0, 1<<n);
	for(int i = 1; i < 1<<n; ++i) {
		mx[i] = max(mx[i], mx[i-1]);
		printf("%d\n", mx[i]);
	}
	return 0;
}
