#include <cstdio>

//#define CHECK_TIME

#ifdef CHECK_TIME
#include <ctime>
#endif

const char InFile[]="punctfix.in";
const char OutFile[]="punctfix.out";
const int MaxN=10111;
const int INF=1<<30;
const int MaxDIFF=131072;
const int BUFFER_SIZE=160111*11;

FILE *fin=fopen(InFile,"r");
FILE *fout=fopen(OutFile,"w");

int N,K,vi,ai,sol,tmin=+INF,tmax=-INF,vsol[MaxDIFF],t[MaxN];
char buffer[BUFFER_SIZE];
char *ptr=buffer;

inline int get()
{
	int semn=1;
	int val=0;
	while(!('0'<=*ptr && *ptr<='9') && *ptr!='-')
	{
		++ptr;
	}
	if(*ptr=='-')
	{
		semn=-1;
		++ptr;
	}
	while('0'<=*ptr && *ptr<='9')
	{
		val*=10;
		val+=*ptr-'0';
		++ptr;
	}
	return val*semn;
}

int main()
{
#ifdef CHECK_TIME
	int start=clock();
#endif
	fread(buffer,BUFFER_SIZE,1,fin);
	N=get();
	for(register int i=1;i<=N;++i)
	{
		ai=get();
		t[i]=i-ai;
		if(t[i]<tmin)
		{
			tmin=t[i];
		}
		if(t[i]>tmax)
		{
			tmax=t[i];
		}
	}
	for(register int i=1;i<=N;++i)
	{
		++vsol[t[i]-tmin];
	}
	K=get();
	for(register int i=1;i<=K;++i)
	{
		vi=get();
		if(vi<tmin || vi>tmax)
		{
			sol=0;
		}
		else
		{
			sol=vsol[vi-tmin];
		}
		fprintf(fout,"%d\n",sol);
	}
	fclose(fin);
	fclose(fout);
	
#ifdef CHECK_TIME
	printf("Time: %lf",(double)(clock()-start)/(double)(CLOCKS_PER_SEC));
#endif
	return 0;
}
