N=int(input()) S=[0]+[s=="E" for s in input()] for i in range(1,N+1): S[i]+=S[i-1] A=[0]+list(map(int,input().split())) for i in range(1,N+1): A[i]+=A[i-1] Q=int(input()) K=list(map(int,input().split())) for k in K: l=0 ans=0 for r in range(N+1): while A[r]-A[l]>k: l+=1 ans=max(ans,S[r]-S[l]) print(ans)