#include <cstdio>

#include <algorithm>

using namespace std;

int n, t;
int v[10005];

int cautare1 (int x)
{
	int st = 1, dr = n, m, sol = n + 1;
	
	while (st <= dr)
	{
		m = (st + dr) >> 1;
		
		if (v[m] >= x)
		{
			sol = m;
			dr = m - 1;
		}
		else
			st = m + 1;
	}
	
	return sol;
}

int cautare2 (int x)
{
	int st = 1, dr = n, m, sol = 0;
	
	while (st <= dr)
	{
		m = (st + dr) >> 1;
		
		if (v[m] <= x)
		{
			sol = m;
			st = m + 1;
		}
		else
			dr = m - 1;
	}
	
	return sol;
}

int main ()
{
	freopen ("punctfix.in", "r", stdin);
	freopen ("punctfix.out", "w", stdout);
	
	scanf ("%d", &n);
	
	int i, x, poz, p1, p2;
	
	for (i = 1; i <= n; i ++)
	{
		scanf ("%d", &x);
		poz = -1 * (x - i);
		v[i] = poz;
	}
	
	sort (v + 1, v + n + 1);
	
	scanf ("%d", &t);
	while (t --)
	{
		scanf ("%d", &x);
		
		p1 = cautare1 (x);
		p2 = cautare2 (x);
		
		if (p1 == 0 || p1 == n + 1 || p2 == 0 || p2 == n + 1)
		{
			printf ("0\n");
			continue;
		}
		if (v[p1] != x)
		{
			printf ("0\n");
			continue;
		}
		
		printf ("%d\n", p2 - p1 + 1);
	}
	
	return 0;
}
