#include <bits/stdc++.h>
using namespace std;
long long rest, ans, G, flag, n, a[200000];
char s[200000];
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  scanf("%s", s + 1);
  for (long long i = 1; i <= n; i++) {
    if (s[i] == 'L') {
      rest -= a[i];
      ans += a[i];
      if (rest < 0) {
        ans += ((flag == 1) ? 3 : 5) * (-rest);
        rest = 0;
      }
    }
    if (s[i] == 'G') {
      rest += a[i];
      ans += 5 * a[i];
      G += 2 * a[i];
    }
    if (s[i] == 'W') {
      flag = 1;
      rest += a[i];
      ans += 3 * a[i];
    }
    G = min(G, rest);
  }
  ans -= rest + G;
  cout << ans << endl;
}
