def calc(K): r = 0 res = 0 k = K for l in range(N): while r=0: k -= A[r] r += 1 res = max(res, acc[r]-acc[l]) if l==r: r += 1 else: k += A[l] return res N = int(input()) S = input() A = list(map(int, input().split())) Q = int(input()) K = list(map(int, input().split())) acc = [0] for Si in S: acc.append(acc[-1]+(1 if Si=='E' else 0)) for Ki in K: print(calc(Ki))