#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define CLR(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
int a[100010];
int main()
{
int n;
while(~scanf("%d",&n))
{
CLR(a,0);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
int q;
scanf("%d",&q);
while(q--)
{
int t;
scanf("%d",&t);
int ans=upper_bound(a+1,a+1+n,t)-a-1;
printf("%d\n",ans);
}
}
return 0;
}