N = int(input()) S = input() A = list(map(int,input().split())) AS = [0] for i in range(N): AS.append(AS[-1] + A[i]) AS.append(float("inf")) SS = [0] for i in range(N): if S[i] == "E": SS.append(SS[-1] + 1) else: SS.append(SS[-1]) Q = int(input()) K = list(map(int,input().split())) for loop in range(Q): nk = K[loop] nans = 0 for root in range(N): l = root r = N + 1 while r - l != 1: m = (l+r) // 2 if AS[m] - AS[root] > nk: r = m else: l = m nans = max(nans , SS[l] - SS[root] ) print (nans)