N=int(input()) S=input() A=list(map(int, input().split())) Q=int(input()) K=list(map(int, input().split())) E=[0] H=[0] e=0 if S=='W'*N: for i in range(Q): print(0) exit() for i in S: if i=='E': e+=1 E.append(e) for i in range(N): H.append(H[-1]+A[i]) D={} for l in range(N): for r in range(l,N): e=E[r+1]-E[l] h=H[r+1]-H[l] if e not in D: D[e]=h else: D[e]=min(D[e],h) ans=[] for i in D: ans.append(D[i]) import bisect for i in range(Q): f=bisect.bisect_right(ans[:-1],K[i]) print(f)