#include using namespace std; #define rep(i,n) for(ll i=0;i<(n);++i) using ll = int; using pll = pair; //constexpr ll INF = (1LL<<60); //constexpr ll MOD = (1e9+7); //constexpr ll MOD = (998244353); template bool chmax(T &a,const T &b){if(a bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} void dump(){cerr< void dump(T&& h, Ts&&... t){cerr<(t)...);} template istream &operator>>(istream&is,vector&v){for(auto &elemnt:v)is>>elemnt;return is;} template istream &operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templatevector make_vector(size_t a){return vector(a);} templateauto make_vector(size_t a, Ts... ts){return vector(ts...))>(a, make_vector(ts...));} signed main(){ ll n; string s; cin>>n>>s; vector a(n); cin>>a; ll q; cin>>q; vector k(q); cin>>k; vector ssum(n+1); rep(i,n)ssum[i+1]=ssum[i]+(s[i]=='E'?1:0); vector asum(n+1); rep(i,n)asum[i+1]=asum[i]+a[i]; auto aasum = make_vector(n,n); auto sssum = make_vector(n,n); rep(i,n)for(ll j=i;jx)break; res=max(res,sssum[i][j]); } return res; }; for(auto x:k){ cout<