#include using namespace std; using i64 = long long; int main() { i64 n; string s; cin >> n >> s; vector a(n); for (i64 i = 0; i < n; i++) cin >> a[i]; i64 q; cin >> q; for (i64 i = 0; i < q; i++) { i64 k; cin >> k; i64 ans = 0, sum = 0, right = 0; for (i64 left = 0; left < n; left++) { while (right < n && sum + a[right] <= k) { sum += a[right]; right++; } ans = max(ans, right - left); if (right == left) right++; else sum -= a[left]; } cout << ans << endl; } return 0; }