#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,a[10010];
int main()
{
	int i,x,poz1,poz2;
	freopen("punctfix.in","r",stdin);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[i]=i-x;
	}
	sort(a+1,a+n+1);
	scanf("%d",&k);
	freopen("punctfix.out","w",stdout);
	for(i=0;i<k;i++)
	{
		scanf("%d",&x);
		poz1=lower_bound(a+1,a+n+1,x)-a;
		if(a[poz1]==x)
		{
			poz2=upper_bound(a+1,a+n+1,x)-a;
			printf("%d\n",poz2-poz1);
		}
		else
			printf("0\n");
	}
	return 0;
}
