#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, Q;
string S;
int A[2123], K[2123];
int mxpos[2123];
ll sum[2123], cnt[2123]; // 1-indexed
int ans[2123];

int main() {
	cin >> N >> S;
	REP(i, N) scanf("%d", A + i);
	cin >> Q;
	REP(i, Q) scanf("%d", K + i);
	
	vector<int> ord(Q);
	iota(ALL(ord), 0);
	
	sort(ALL(ord), [&](int x, int y) {
		return K[x] < K[y];
	});
	
	REP(i, N) {
		sum[i + 1] = sum[i] + A[i];
		cnt[i + 1] = cnt[i] + (S[i] == 'E');
	}
	
	iota(mxpos, mxpos + N, 0);
	
	int mx = 0;
	for (int curq : ord) {
		// K[curq]までいける
		REP(i, N) {
			int cur = mxpos[i];
			while (cur < N && sum[cur + 1] - sum[i] <= K[curq]) cur++;
			mxpos[i] = cur;
			chmax(ans[curq], cnt[cur] - cnt[i]);
		}
	}
	
	REP(i, Q) printf("%d\n", ans[i]);
	
	return 0;
}