from bisect import bisect_right n = int(input()) S = input() A = list(map(int, input().split())) inf = 1 << 60 min_ = [inf] * n for i in range(n): tot = 0 e = 0 for j in range(i, n): tot += A[j] if S[j] == "E": min_[e] = min(min_[e], tot) e += 1 q = int(input()) K = list(map(int, input().split())) for k in K: print(bisect_right(min_, k))