#include using namespace std; template int SumDigit(T N) { int res = 0; while(N > 0) { res += (N % 10); N /= 10; } return res; } int main(){ int N, Q; string S; cin >> N >> S; vector HP(N); vector sum(N+1, 0); vector ene(N+1, 0); for (int i = 0; i < N; i++) { cin >> HP[i]; sum[i+1] = sum[i] + HP[i]; ene[i+1] = ene[i]; if (S[i] == 'E') ene[i+1]++; } cin >> Q; for (int i = 0; i < Q; i++) { long long K; cin >> K; int ans = 0; if (sum[N] <= K) { cout << ene[N] << endl; continue; } for (int j = 0; j < N; j++) { long long k = K + sum[j]; int m = lower_bound(sum.begin(), sum.end(), k) - sum.begin(); int res; if (m > 0 && sum[m-1] <= k) res = ene[m-1] - ene[j]; if (sum[m] <= k) res = ene[m] - ene[j]; if (m < N && sum[m+1] <= k) res = ene[m+1] - ene[j]; ans = max(ans, res); } cout << ans << endl; } return 0; }