from collections import defaultdict

n=  int(input())
arr  =[]
hash_map= defaultdict(int)
for i in range(0 , n):
	num= int(input())
	arr.append(num)
	hash_map[num]+=1
	
q = int(input())
for j in range(0 , q):
	query= int(input())
	count  = hash_map[query]
	print(count)
	