#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define INF 1000000000000000000 int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string s; cin >> s; vector A(N), ene; rep(i, N) { cin >> A[i]; } rep(i, N - 1) { A[i + 1] += A[i]; } rep(i, N) { if (s[i] == 'E') { ene.push_back(A[i]); cout << A[i] << " "; } } cout << endl; int Q; cin >> Q; rep(i, Q) { ll q; cin >> q; ll ans = 0; rep(j, ene.size()) { ll tmp = lower_bound(all(ene), q + ene[j]) - ene.begin(); tmp -= j; ans = max(ans, tmp); } cout << ans << endl; } }