#include <bits/stdc++.h>//P1918 保龄球 sytem()
using namespace std;
struct ball{
int n;
int x;
}A[100000000];
bool cmp(ball a,ball b){
return a.n <b.n ;
}
int main(){
int n;
cin>>n;
int n1;
for(int i=0;i<n;i++){
cin>>A[i].n;
A[i].x =i;
}
sort(A+1,A+n+1,cmp);
unsigned long long ind;
unsigned long long l=0;
unsigned long long r=n-1;
cin>>n1;
for(int i=0;i<n1;i++){
int asd;
cin>>asd;
bool a=1;
l=0;
r=n-1;
while(l<r){
ind=(l+r)/2;
if(A[i].n<asd){
l++;
}
if(A[i].n ==asd){
cout<<A[l].x ;
a=0;
break;
}
}
if(a==1){
cout<<"0";
}
}
}