#include <stdio.h>
#include <stdlib.h>
// 오름차순 정렬
int compare (const void *first, const void *second)
{
if (*(int*)first > *(int*)second)
return 1;
else if (*(int*)first < *(int*)second)
return -1;
else
return 0;
}
int main(int argc, char* argv[]) {
int n1, n2, i;
int *arr1, *arr2;
int B_S(int *arr, int size, int solution);
scanf("%d", &n1);
arr1 = (int *)malloc(sizeof(int) * n1);
for(i=0; i<n1; i++) scanf("%d", &arr1[i]);
// 정렬
qsort(arr1, n1, sizeof(int), compare);
scanf("%d", &n2);
arr2 = (int *)malloc(sizeof(int) * n2);
for(i=0; i<n2; i++) scanf("%d", &arr2[i]);
// 서치
for(i=0; i<n2; i++) {
printf("%d\n", B_S(arr1, n1, arr2[i]));
}
return 0;
}
// 바이너리 서치
int B_S(int *arr, int size, int solution) {
int s=0, e=size-1;
int m;
while(s <= e) {
m = (s+e)/2;
if(arr[m] > solution) e = m - 1;
else if(arr[m] < solution) s = m + 1;
else return 1;
}
return 0;
}