#include<bits/stdc++.h>
using namespace std;
#define fastkor ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ll long long
#define dvect vector<int>vect
#define pb(x) push_back(x)
#define vectinL(n) for(ll i=0;i<n;i++){ ll x; cin >> x; vect.push_back(x);}
#define vectin(n) for(int i=0;i<n;i++){ int x; cin >> x; vect.push_back(x);}
#define vectout(v) for(auto p: v) cout<<p<<" "; cout<<endl;
#define sortkor(x) sort(x.begin(),x.end())
#define reversekor(x) reverse(x.begin(),x.end())
#define all(vect) vect.begin(),vect.end()
#define mini_pos(a) ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi_pos(a) ( max_element((a).begin(), (a).end()) - (a).begin())
#define F first
#define S second
#define gcd(a,b) __gcd(a,b)
#define YES1 cout<<"Case "<<case++<<": YES\n"
#define NO1 cout<<"Case "<<case++<<": NO\n"
#define precision(n) fixed<<setprecision(n)
#define testcase ll t; cin >>t; while(t--)
#define yes cout<<"yes\n";
#define Yes cout<<"Yes\n";
#define YES cout<<"YES\n"
#define no cout<<"no\n";
#define No cout<<"No\n";
#define NO cout<<"NO\n"
#define vectd vector<ll>vect(n)
const int N=2e5+10;
vector<pair<int,int>>moves=
{
{-1,0},{1,0},{0,-1},{0,1}
};
const int mod=1e9+7;
ll fact[N+10];
vector<bool>isprime;
vector<int>primegula;
map<int,int>mp;
template <typename T>
inline void operator>>(istream &istream, vector<T> &v)
{
for (T &i : v)
{
cin >> i;
}
}
int main()
{
fastkor;
ll n,m;
cin >> n;
vector<ll>vect(n);
map<ll,ll>mp1;
cin >> vect;
for(auto x: vect)
{
mp1[x]++;
// cout<<x<<" "<<mp1[x]<<" ";
}
// cout<<"\n\n";
cin >> m;
vector<ll>v2(m);
vector<ll>v(m);
for(int i=0; i<m; i++)
{
cin >> v2[i];
v[i]=v2[i];
}
sortkor(vect);
sortkor(v2);
vector<ll>an(m,0);
ll prev=0;
for(int i=0; i<m; i++)
{
int l1=0;
int h1=n-1;
int mid1;
int ans=0;
while(l1<=h1)
{
mid1=(l1+h1)/2;
if(vect[mid1]>v[i])
{
h1=mid1-1;
//ans=mid1;
}
else{
l1=mid1+1;
ans=mid1+1;
}
}
int l2=0;
int h2=m-1;
int mid2;
int ans2=0;
while(l2<=h2)
{
mid2=(l2+h2)/2;
if(v2[mid2]>v[i])
{
h2=mid2-1;
}
else{
l2=mid2+1;
ans2=mid2+1;
}
}
ll ans3=ans+ans2;
ans3--;
// cout<<ans<<" "<<ans2<<" ";
cout<<(n+m)-ans3+mp1[v[i]];
if(i<m-1)
cout<<" ";
mp1[v[i]]++;
}
}