import java.util.*;
public class Main{
public static void main
(String args
[]){ Scanner sc
=new Scanner
(System.
in); HashMap
<Integer,Integer
>hm
=new HashMap
<>(); int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
for(int i=0;i<n;i++){
hm.put(arr[i],hm.getOrDefault(arr[i],0)+1);
}
int q=sc.nextInt();
for(int i=0;i<q;i++){
int qq=sc.nextInt();
System.
out.
println(hm.
getOrDefault(qq,
0)); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKcHVibGljIGNsYXNzIE1haW57CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKXsKICAgICAgICBTY2FubmVyIHNjPW5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgSGFzaE1hcDxJbnRlZ2VyLEludGVnZXI+aG09bmV3IEhhc2hNYXA8PigpOwogICAgICAgIGludCBuPXNjLm5leHRJbnQoKTsKICAgICAgICBpbnRbXSBhcnI9bmV3IGludFtuXTsKICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgICAgICAgICAgYXJyW2ldPXNjLm5leHRJbnQoKTsKICAgICAgICB9CiAgICAgICAgZm9yKGludCBpPTA7aTxuO2krKyl7CiAgICAgICAgICAgIGhtLnB1dChhcnJbaV0saG0uZ2V0T3JEZWZhdWx0KGFycltpXSwwKSsxKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaW50IHE9c2MubmV4dEludCgpOwogICAgICAgIGZvcihpbnQgaT0wO2k8cTtpKyspewogICAgICAgICAgICBpbnQgcXE9c2MubmV4dEludCgpOwogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oaG0uZ2V0T3JEZWZhdWx0KHFxLDApKTsKICAgICAgICB9CiAgICB9Cn0=