import sys def printe(*args, end="\n", **kwargs): print(*args, end=end, file=sys.stderr, **kwargs) def main(): N = int(input()) A = list(map(int, input().split())) history_x = [] history_mod = {} c_x = 0 c_n = 0 while (c_x % N) not in history_mod: history_x.append(c_x) history_mod[c_x % N] = c_n c_x += A[c_x % N] c_n += 1 printe(history_mod) printe(history_x) loop_interval = c_n - history_mod[c_x % N] init = history_mod[c_x % N] printe(loop_interval, init, c_x) increase = c_x - history_x[init] for _ in range(int(input())): K = int(input()) if K < init: print(history_x[K]) continue loop_n = (K - init) // loop_interval loop_rest = (K - init) % loop_interval print(history_x[init] + increase * loop_n + history_x[init + loop_rest] - history_x[init]) if __name__ == "__main__": main()