#include<fstream>
#include<iostream>
using namespace std;
typedef struct { long val, count; } tip;
tip T[10005];
long n,cs,s,m,i,nr,val,k,quest;

long bs(long st, long dr, long val)
{
	long m;
	m=(st+dr)/2;
	if(T[m].val==val)
		return m;
	if(st>=dr)
		return dr;
	if(T[m].val>val)
		return bs(m+1,dr,val);
	else
		return bs(st,m-1,val);
	
}

int main()
{
	ifstream in("punctfix.in");
	ofstream out("punctfix.out");
	in>>n;
	in>>val;
	nr=1;
	T[nr].val=(1-val);
	T[nr].count=1;
	for(i=2; i<=n; ++i)
	{
		in>>val;
		if(i-val==T[nr].val)
			T[nr].count++;			
		else{
			nr++;
			T[nr].val=(i-val);
			T[nr].count++;
		}			
	}
	s=1;
	while(s<nr)
		s*=2;
	in>>k;
	for(i=1; i<=k; ++i)
	{
		in>>quest;
	/*	cs=(s>>1);
		m=s/2;
		while(cs)
		{
			if(T[m].val==quest)
				break ;
			if(T[m].val>quest)
			{
				cs=(cs>>1);
				m+=cs;
			}
			else{
				cs=(cs>>1);
				m-=cs;
			}
		}*/
		m=bs(1,nr,quest);
		if(T[m].val==quest)
			out<<T[m].count<<"\n";
		else
			out<<"0\n";
	}
	in.close();
	out.close();
	return 0;
}
