# include <cstdio>
# include <fstream>
using namespace std;


//NU UITA SA FACI CU FSTREAM !!!!!!!!!!!!!!

int n, m, i, j, cit, a[150005], ap[600100];
int VAL = 150020;
int _min = 2000000000;
int _max = -2000000000;
int main (){
	freopen ("punctfix.in", "r", stdin);
	ofstream g ("punctfix.out");
	
	scanf ("%d", &n);
	for (i = 1; i <= n; ++i){
		scanf ("%d", &a[i]);
		if (_min > a[i]) _min = a[i];
	}
	for (i = 1; i <= n; ++i){
		++ap[i - a[i] + _min + VAL];
	}
	scanf ("%d", &m);
	for (i = 1; i <= m; ++i){
		scanf ("%d", &cit);
		if (cit + _min + VAL < -300000 || cit + _min + VAL > 300000){
			g << "0\n";
		}
		else
			g << ap[cit + _min + VAL] << '\n';
	}
	return 0;
}