#include<stdio.h>

FILE *fin=fopen("punctfix.in","r");
FILE *fout=fopen("punctfix.out","w");

long n,k;
long a[100005];
long c[100005];
long min=1000000000;
long p[100005];

int main()
{
	fscanf(fin,"%ld\n",&n);
	
	for(int i=1; i<=n; i++)
	{
	  fscanf(fin,"%ld",&a[i]);
	  c[i]=i-a[i];
	  if(min>c[i])
	  min=c[i];
	}
	fscanf(fin,"\n");
	for(int i=1; i<=n; i++)
	{
	c[i]=c[i]+(0-min);
	p[c[i]]++;
	}
	
	fscanf(fin,"%ld\n",&k);
	for(int o=1; o<=k; o++)
	{
	  long v;
	  fscanf(fin,"%ld",&v);
	  
	  if(v+(0-min)>=0)
	  fprintf(fout,"%ld\n",p[v+(0-min)]);
	  else
	  fprintf(fout,"0\n");
	}
	
fclose(fin);
fclose(fout);
return 0;
}
