#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, Q, K;
long long A[1 << 18];
long long used[1 << 18];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) used[i] = -1;

	vector<long long> v1; long long cx = 0, cnt = 0, pre = 0;
	while (true) {
		v1.push_back(cx); used[cx % N] = cnt;
		cx += A[cx % N]; cnt += 1;
		if (used[cx % N] != -1) {
			pre = used[cx % N];
			break;
		}
	}

	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> K;
		if (K < pre) {
			cout << v1[K] << endl;
		}
		else {
			long long E1 = ((K - pre) / (long long)(v1.size() - pre));
			long long E2 = ((K - pre) % (long long)(v1.size() - pre));
			cout << E1 * (cx - v1[pre]) + v1[E2 + pre] << endl;
		}
	}
	return 0;
}