N,M=map(int, input().split()) *A,=map(int, input().split()) S=input() l=0 r=N-1 k=0 i=0 for s in S: if s=='L': i-=1 l=max(l,-i) k=max(0,k-1) else: i+=1 r=min(r,N-1-i) k=min(N-1,k+1) ans=[0]*N for i in range(N): if i<=l: ans[k]+=A[i] elif i