#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n], i;
  for (i = 0; i < n; i++) cin >> a[i];
  bool wtr = false;
  string s;
  cin >> s;
  long long int t = 0, st = 0, g = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 'L') {
      t += a[i];
      st -= a[i];
      if (st < 0) {
        t -= st * (wtr ? 3 : 5);
        st = 0;
      }
    } else if (s[i] == 'W') {
      wtr = true;
      t += 3 * a[i];
      st += a[i];
    } else {
      t += 5 * a[i];
      st += a[i];
      g += 2 * a[i];
    }
    g = min(g, st);
  }
  if (st > 0) {
    t -= (5 - 1) * g / 2;
    t -= (3 - 1) * (st - g) / 2;
  }
  cout << t;
  return 0;
}
