#include "iostream"
#include "math.h"
using namespace std;

int N;
int hard[300000];
bool flag[300000];
int f;

int main() {
	cin >> N;
	for (int i = 0; i < pow(2, N); i++) {
		cin >> hard[i];
		flag[i] = true;
	}
	f = -1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < pow(2, N); j++) {
			if (flag[j]) {
				if (f == -1) {
					f = j;
				}
				else {
					if (hard[f] == hard[j]) {
						flag[f] = false;
					}
					else if (hard[f] > hard[j]) {
						flag[j] = false;
						hard[f] -= hard[j];
					}
					else {
						flag[f] = false;
						hard[j] -= hard[f];
					}
					f = -1;
				}
			}
		}
	}
	for (int i = 0; i < pow(2, N); i++) {
		if (flag[i]) {
			cout << hard[i] << "\n";
		}
	}
	return 0;
}