#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
FILE *f,*g;
int v[15000];
struct cp{int x,y;} ax;
vector <int> a;
vector <cp> b;
int rasp,n,i,nr,k,j,nn;
int sol[300000],mj;

void caut(int i,int j, int x) {
int m;

if (i<=j) {
	m=(i+j)/2;
	if (b[m].x==x) {
		rasp=m;
		}
	else {
		if (b[m].x>x) 
			caut (i,m-1,x);
		else
			caut(m+1,j,x);
		}
	
	}

}


int main() {
f=fopen("punctfix.in","r");
g=fopen("punctfix.out","w");

fscanf(f,"%d",&n);

for (i=1;i<=n;i++) {
	fscanf(f,"%d",&v[i]);
	nr=i-v[i];
	a.push_back(nr);
	}

sort(a.begin(),a.end());

/*for (i=0;i<a.size();i++)
	fprintf(g,"%d ",a[i]);*/

for (i=0;i<n;i=j) {
	ax.x=a[i];
	ax.y=0;
	for (j=i;j<=n && a[j]==ax.x;j++)  {
		ax.y++;
		}
	b.push_back(ax);
	}

nn=b.size()-1;




fscanf(f,"%d",&k);

fscanf(f,"%d",&nr);
mj=nr;

for (i=0;i<b.size();i++) {
	if (b[i].x>=mj-100100 && b[i].x<=mj+100100) {
		sol[b[i].x - (mj-100100)] = b[i].y;
		}
	}
fprintf(g,"%d\n",sol[nr-(mj-100100)]);


for (i=2;i<=k;i++) {
	fscanf(f,"%d",&nr);
	fprintf(g,"%d\n",sol[nr-(mj-100100)]);
	}

fclose(g);
return 0;
}