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:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,abm,mmx,tune=native")
#include<vector>
#include<iostream>
#include<stack>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<tuple>
#include<bitset>
#include<queue>
#include<unordered_map>
#include<random>
#include<ctime>
//#include<complex>
#include<numeric>
typedef long long ll;
typedef long double ld;
typedef unsigned short us;
typedef unsigned long long ull;
//typedef complex<double> base;
using namespace std;
ll gcd(ll i, ll j) {
	if (j == 0)return i;
	else return gcd(j, i % j);
}
#ifdef _DEBUG
int __builtin_popcount(int x) { return x ? (__builtin_popcount(x >> 1) + (x & 1)) : 0; }
#endif
template<typename T> inline T getint() {
	T val = 0;
	char c;

	bool neg = false;
	while ((c = getchar()) && !(c >= '0' && c <= '9')) {
		neg |= c == '-';
	}

	do {
		val = (val * 10) + c - '0';
	} while ((c = getchar()) && (c >= '0' && c <= '9'));

	return val * (neg ? -1 : 1);
}
//#define int long long
const ll INF = 1e9 + 100;
const int mod = 1000000007;
const ld eps = 1e-6, pi = acosl(-1);
const ll maxN = 10210, maxT = 10010, A = 179, mid = 150;
mt19937 mt_rand(time(0));
ll bp(ll et, ll b) {
	b %= mod - 1;
	ll res = 1;
	for (int i = 30; i >= 0; --i) {
		res = (res * res) % mod;
		if ((b & (1 << i)) != 0)res = (res * et) % mod;
	}
	return res;
}
void panic() {
	cout << "-1\n";
	exit(0);
}
int pl(const int& a, const int& b) {
	int r = a + b;
	if (r >= mod)r -= mod;
	return r;
}
vector<ll>c, b;
map<ll, ll>mp;
int n;
bool check_0(ll x) {
	ll d = 0, s = 0;
	bool ff = 1;
	for (int i = 0; i < n; ++i) {
		if (i) {
			d += b[i - 1];
			s += d;
		}
		ll vv = x * (i + 1) + s;
		ff &= vv <= 0;
	}
	return ff;
}
bool check_1(ll x) {
	ll d = 0, s = 0;
	bool ff = 0;
	ll sum_s = 0;
	for (int i = 0; i < n; ++i) {
		sum_s += c[i];
		if (i) {
			d += b[i - 1];
			s += d;
		}
		ll vv = x * (i + 1) + s;
		ff |= sum_s < vv;
	}
	return ff;
}
ll get_r(ll x) {
	if (mp.count(x))
		return mp[x];
	if (check_0(x)) {
		ll r = 1;
		for (auto x : c) {
			r = (r * (x + 1)) % mod;
		}
		return mp[x] = r;
	}
	if (check_1(x)) {
		return mp[x] = 0;
	}
	ll d = 0, s = 0;
	vector<vector<ll>>dp(n + 1, vector<ll>(maxN));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		if (i) {
			d += b[i - 1];
			s += d;
		}
		ll vv = x * (i + 1) + s;
		ll cc = c[i];
		for (int j = maxN - cc - 2; j >= 0; --j) {
			if (j + cc < vv)
				break;
			dp[i + 1][max(vv, (ll)j)] = pl(dp[i + 1][max(vv, (ll)j)], dp[i][j]);
			dp[i + 1][j + cc + 1] = pl(dp[i + 1][j + cc + 1], mod - dp[i][j]);
		}
		for (int j = 1; j < maxN; ++j) {
			dp[i + 1][j] = pl(dp[i + 1][j], dp[i + 1][j - 1]);
		}
	}
	ll ans = 0;
	for (int i = 0; i < maxN; ++i)
		ans = pl(ans, dp[n][i]);
	return mp[x] = ans;
}
void solve() {
	cin >> n;
	c.assign(n, 0);
	b.assign(n - 1, 0);
	for (auto& x : c)
		cin >> x;
	for (auto& x : b)
		cin >> x;
	int q;
	cin >> q;
	while (q--) {
		ll x;
		cin >> x;
		cout << get_r(x) << "\n";
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.precision(20);
	//srand(time(0));
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//freopen("gymnasts.in", "r", stdin); freopen("gymnasts.out", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}