import sys
input = sys.stdin.readline
N = int(input())
li = set(input().split())
M = int(input())
answer = ''
for num in input().split():
answer += "1\n" if num in li else "0\n"
print(answer)
import sys
def solution():
N = int(sys.stdin.readline().rstrip())
li = list(map(int,sys.stdin.readline().rstrip().split(" ")))
M = int(sys.stdin.readline().rstrip())
li2 = list(map(int,sys.stdin.readline().rstrip().split(" ")))
answer = ''
li.sort()
for i in range(M):
answer += search(li,0,N-1, li2[i])
return answer
def search(array ,start ,end , answer):
while start <= end :
pivot = (start+end) // 2
if(array[pivot] == answer):
return '1\n'
elif(array[pivot] > answer):
end = pivot-1
elif(array[pivot] < answer):
start = pivot+1
return '0\n'
print(solution())