#include<iostream>

using namespace std;

void Binary_Search(int *A, int n, int key);

int main() {
	
	int *A;
	int n;
	cin >> n;
	
	A = new int [n];
	
	for(int i=0;i<n;i++)
		cin >> A[i];
	
	int n2;
	cin >> n2;
	
	int key;
	
	for(int i=0;i<n2;i++) {
		cin >> key;
		Binary_Search(A, n, key);
	}
	
	return 0;
}

void Binary_Search(int *A, int n, int key) {
	int low = 0;
	int up = n - 1;
	while(low <= up) {
		int mid = low + (up - low) / 2;
		if( A[mid] == key) {
			cout << "1\n";
			return ;
	}
		else if ( A[mid] > key )
			up = mid - 1;
			
		else
			low = mid + 1;
	}
		cout << "0\n";
}
