n = int(input()) S = input() A = list(map(int,input().split())) q = int(input()) K = list(map(int,input().split())) sK = sorted([[k,i] for i,k in enumerate(K)]) ans = [0]*q for i in range(n): num = 0 now = i hp = 0 for k,ind in sK: while now < n and hp+A[now] <= k: hp += A[now] if S[now] == "E": num += 1 now += 1 ans[ind] = max(ans[ind],num) for i in ans: print(i)