#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; if (sum[N] <= K) { cout << ene[N] << endl; continue; } int M = lower_bound(sum.begin(), sum.end(), K) - sum.begin(); int ans = ene[M]; if (K < sum[M] && S[M] == 'E') ans = max(0, ene[M]-1); cout << ans << endl; } }