#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	int nplayers = 1 << N; // 1 << N is the N-th power of 2
	vector<int> V(nplayers);
	for (int &x : V) {
		scanf("%d", &x);
	}
	int dudu = V[0];
	sort(V.begin(), V.end());
	if (N == 0 || V[0] != dudu || V[1] == dudu) { // it is possible
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}
