N=int(input()) S=input() A=list(map(int, input().split())) Q=int(input()) K=list(map(int, input().split())) E=[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(Q): hp=K[i] l,r=0,0 hp-=A[0] e=E[r+1]-E[l] ans,d=0,0 if hp>=0 and S[0]=='E': d+=1 ans=1 while r=0: ans=max(d,ans) if r==N-1: print(ans) break