Problem: This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved.

There is a process that takes place on arrays a and b of length n and length n-1 respectively. 

The process is an infinite sequence of operations. Each operation is as follows: 

  * First, choose a random integer i (1 ≤ i ≤ n-1). 
  * Then, simultaneously set a_i = min\left(a_i, \frac{a_i+a_{i+1}-b_i}{2}\right) and a_{i+1} = max\left(a_{i+1}, \frac{a_i+a_{i+1}+b_i}{2}\right) without any rounding (so values may become non-integer). 

See notes for an example of an operation.

It can be proven that array a converges, i. e. for each i there exists a limit a_i converges to. Let function F(a, b) return the value a_1 converges to after a process on a and b.

You are given array b, but not array a. However, you are given a third array c. Array a is good if it contains only integers and satisfies 0 ≤ a_i ≤ c_i for 1 ≤ i ≤ n.

Your task is to count the number of good arrays a where F(a, b) ≥ x for q values of x. Since the number of arrays can be very large, print it modulo 10^9+7.

Input

The first line contains a single integer n (2 ≤ n ≤ 100).

The second line contains n integers c_1, c_2 …, c_n (0 ≤ c_i ≤ 100).

The third line contains n-1 integers b_1, b_2, …, b_{n-1} (0 ≤ b_i ≤ 100).

The fourth line contains a single integer q (1 ≤ q ≤ 10^5).

The fifth line contains q space separated integers x_1, x_2, …, x_q (-10^5 ≤ x_i ≤ 10^5).

Output

Output q integers, where the i-th integer is the answer to the i-th query, i. e. the number of good arrays a where F(a, b) ≥ x_i modulo 10^9+7.

Example

Input


3
2 3 4
2 1
5
-1 0 1 -100000 100000


Output


56
28
4
60
0

Note

The following explanation assumes b = [2, 1] and c=[2, 3, 4] (as in the sample).

Examples of arrays a that are not good: 

  * a = [3, 2, 3] is not good because a_1 > c_1; 
  * a = [0, -1, 3] is not good because a_2 < 0. 



One possible good array a is [0, 2, 4]. We can show that no operation has any effect on this array, so F(a, b) = a_1 = 0.

Another possible good array a is [0, 1, 4]. In a single operation with i = 1, we set a_1 = min((0+1-2)/(2), 0) and a_2 = max((0+1+2)/(2), 1). So, after a single operation with i = 1, a becomes equal to [-1/2, 3/2, 4]. We can show that no operation has any effect on this array, so F(a, b) = -1/2.

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <cstring>
#include <map>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;

template <class T>
T fexp(T x, long long e) {
	T ans(1);
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x;
		x = x * x;
	}
	return ans;
}

template <int mod = MOD>
struct modBase {
	modBase(int v = 0) : val(v < 0 ? v + mod : v) {}
	int val;
 
	void operator += (modBase<mod> o) { *this = *this + o; }
	void operator -= (modBase<mod> o) { *this = *this - o; }
	void operator *= (modBase<mod> o) { *this = *this * o; }
	//void operator /= (modBase<mod> o) { *this = *this / o; }
	modBase<mod> operator * (modBase<mod> o) { return (int)((long long) val * o.val % mod); }
	modBase<mod> operator / (modBase<mod> o) { return *this * fexp(o, mod - 2); }
	modBase<mod> operator + (modBase<mod> o) { return val + o.val >= mod ? val + o.val - mod : val + o.val; }
	modBase<mod> operator - (modBase<mod> o) { return val - o.val < 0 ? val - o.val + mod : val - o.val; }

	friend std::ostream& operator << (std::ostream &os, const modBase<mod> &p) {
		return os << p.val;
	}
	friend std::istream& operator >> (std::istream &is, modBase<mod> &p) {
		return is >> p.val;
	}
};

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> rangeSize(n);
	for(int i = 0; i < n; i++) {
		std::cin >> rangeSize[i];
	}
	std::vector<modBase<>> val(n+1, 1);
	for(int i = n-1; i >= 0; i--) {
		val[i] = val[i+1] * (1 + rangeSize[i]);
	}
	std::vector<int> offset(n, 0);
	for(int i = 1; i < n; i++) {
		std::cin >> offset[i];
		offset[i] += offset[i-1];
	}
	int worstCase = 0;
	for(int i = 0; i < n; i++) {
		worstCase = std::max(worstCase, offset[i]);
	}
	std::map<int, modBase<>> memo;
	std::vector<int> a(n);
	auto qry = [&](int x) {
		x = -x;
		//if(x < 0) return modBase<>(0);
		//x = std::min(x, worstCase);
		if(memo.count(x)) return memo[x];
		//std::cout << "solving for " << x << std::endl;
		std::vector<modBase<>> cur(1, 1);
		for(int i = 0; i < n; i++) {
			a[i] = x - offset[i];
		}
		// use this to check if it dies, if it doesn't just add to answer
		std::vector<int> worst(n+1, 0);
		for(int i = n-1; i >= 0; i--) {
			worst[i] = std::min(worst[i+1] + a[i], 0);
		}
		// use this to check if it can stay alive
		std::vector<int> best(n+1, 0);
		for(int i = n-1; i >= 0; i--) {
			best[i] = std::max(best[i+1], 0) + a[i] + rangeSize[i];
		}
		int curSum = 0;
		modBase<> ans(0);
		for(int i = 0; i < n && !cur.empty(); i++) {
			//std::cout << "for " << i << " starting at " << curSum << '\n';
			std::vector<modBase<>> nxt(cur.size() + rangeSize[i] + 1, 0);
			for(int j = 0; j < (int) cur.size(); j++) {
				nxt[j] += cur[j];
				nxt[j + rangeSize[i] + 1] -= cur[j];
			}
			for(int j = 1; j < (int) nxt.size(); j++) {
				nxt[j] += nxt[j-1];
			}
			while(!nxt.empty() && nxt.back().val == 0) nxt.pop_back();
			int l = 0, r = (int) nxt.size();
			curSum += a[i];
			// check dead stuff
			while(l < r && curSum + l < 0) {
				l++;
			}
			while(l < r && curSum + l + best[i+1] < 0) {
				l++;
			}
			// check alive stuff
			while(r > l && curSum + (r-1) + worst[i+1] >= 0) {
				r--;
				ans += nxt[r] * val[i+1];
			}
			cur.resize(r - l);
			for(int j = l; j < r; j++) {
				cur[j - l] = nxt[j];
			}
			curSum += l;
		}
		//assert(cur.empty());
		for(auto i : cur) ans += i;
		return memo[x] = ans;
	};
	int q;
	std::cin >> q;
	while(q--) {
		int x;
		std::cin >> x;
		std::cout << qry(x) << '\n';
	}
}