def median_search(A, key):
L = 0
R = 0
S = 0
for i in range(len(A)):
if A[i] == key:
L = i + 1
while A[i] == key:
R = i + 1
S = (L + R) // 2
return S
N = int(input())
A = list(map(int, input().split(maxsplit=N)))
M = int(input())
B = list(map(int, input().split(maxsplit=M)))
for j in range(len(B)):
lb = median_search(A, B[j])
if lb != 0:
print(lb, end='')
else:
print(0, end='')
while A[i] == key:
R = i + 1