import sys


def sol():
    input = sys.stdin.readline
    N = int(input())
    number_cards = list(map(int, input().split()))
    number_cards_dict = dict()
    for i in range(N):
        number = number_cards[i]
        if number not in number_cards_dict:
            number_cards_dict[number] = 0
        number_cards_dict[number] += 1
    M = int(input())
    arr = list(map(int, input().split()))
    for i in range(M):
        target_number = arr[i]
        if target_number not in number_cards_dict:
            print(0, end=" ")
        else:
            print(number_cards_dict[target_number], end=" ")


if __name__ == "__main__":
    sol()

import sys


def sol():
    input = sys.stdin.readline
    N = int(input())
    number_cards = list(map(int, input().split()))
    number_cards_dict = dict()
    for i in range(N):
        number = number_cards[i]
        if number not in number_cards_dict:
            number_cards_dict[number] = 0
        number_cards_dict[number] += 1
    M = int(input())
    arr = list(map(int, input().split()))
    for i in range(M):
        target_number = arr[i]
        if target_number not in number_cards_dict:
            print(0, end=" ")
        else:
            print(number_cards_dict[target_number], end=" ")


if __name__ == "__main__":
    sol()
