# include <cstdio>
using namespace std;
long a[10010],b[10010];
long i,j,n,k,p,st,dr,med,x,sol;
int main()
{
	freopen("punctfix.in","r",stdin);
	freopen("punctfix.out","w",stdout);
	scanf("%ld",&n);
	p=0;
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&x);
		if (i-x!=a[p] || p==0)
		{
			p++;
			a[p]=i-x;
			b[p]=1;
		} else if (i-x==a[p]) b[p]++;
	}
	scanf("%ld",&k);
	for (i=1;i<=k;i++)
	{
		scanf("%ld",&x);
		st=1;
		dr=p;
		sol=0;
		if (x>a[st] || x<a[dr]) st=dr+1;
		while (st<=dr)
		{
			med=st+dr+1;
			med=med>>1;
			if (a[med]>x) st=med+1;
			if (a[med]<x) dr=med-1;
			if (a[med]==x) {dr=0; sol=b[med];}
		}
		printf("%ld",sol);
		if (i!=k) printf("\n");
	}
	return 0;
}
