#include<cstdio>
using namespace std;


int mi,ma,i,a[100000],v[150001],nr[1000000],x,k,n;



int main()
{
	freopen("punctfix.in","r",stdin);
	freopen("punctfix.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",&a[i]);
	scanf("%d",&k);
	mi=2000000000;
	ma=-2000000000;
	for(i=1;i<=k;++i)
	{
		scanf("%d",&v[i]);
		if (v[i]<mi)
			mi=v[i];
		if (v[i]>ma)
			ma=v[i];
	}
	for(i=1;i<=n;++i)
	{
		x=i-a[i];
		if (!(x<=ma && x>=mi))
			continue;
		nr[x-mi]++;
	}
	for(i=1;i<=k;++i)
		printf("%d\n",nr[v[i]-mi]);
	return 0;
}