#include<cstdio>
using namespace std;

#define initx 2000000000

int n, k, a[10001];
int x = initx, tr[120002];

int main() {
	int i, t;
	
	freopen("punctfix.in", "r", stdin);
	freopen("punctfix.out", "w", stdout);
	scanf("%d", &n);
	for(i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		if(i - a[i] < x)
			x = i - a[i];
	}
	
	for(i = 1; i <= n; ++i) 
		++tr[i - a[i] - x];
	
	scanf("%d", &k);
	for(i = 1; i <= k; ++i) {
		scanf("%d", &t);
		if(t + x > 120000)
			printf("0\n");
		else
			printf("%d\n", tr[t - x]);
	}
	return 0;
}
