#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a[12000];
int bs2(int x)
{
	int st=1,dr=n,med,last=-1;
	while(st<=dr)
	{
		med=st+((dr-st)>>1);
		if(a[med]==x)
		{
			last=med;
			st=med+1;
		}
		if(a[med]>x)
			dr=med-1;
		if(a[med]<x)
			st=med+1;
	}
	return last;
}
int bs1(int x)
{
	int st=1,dr=n,med,last=0;
	while(st<=dr)
	{
		med=st+((dr-st)>>1);
		if(a[med]==x)
		{
			last=med;
			dr=med-1;
		}
		if(a[med]>x)
			dr=med-1;
		if(a[med]<x)
			st=med+1;
	}
	return last;
}
int bfs(int x)
{
	return (bs2(x)-bs1(x)+1);
}
int main()
{
	freopen("punctfix.in","r",stdin);
	freopen("punctfix.out","w",stdout);
	int k,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{	
		scanf("%d",&x);
		a[i]=i-x;
	}
	scanf("%d",&k);
	sort(a+1,a+n+1);
	for(i=1;i<=k;i++)
	{
		scanf("%d",&x);
		printf("%d\n",bfs(x));
	}
	return 0;
}
