#include <bits/stdc++.h>
using namespace std;
const int N = 10000;
const long double pi = acos(-1.0);
int n;
long long l[200200];
char s[200200];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) scanf("%lld", &l[i]);
  scanf("%s", s + 1);
  long long ans = 0, minsum = 1e18, sum = 0, num = 0;
  bool opw = 0;
  for (register int i = 1; i <= n; i++) {
    if (s[i] == 'G') {
      sum += l[i];
      ans += l[i] * 5;
      num += (l[i] << 1);
    } else if (s[i] == 'W') {
      sum += l[i];
      ans += l[i] * 3;
      opw = 1;
    } else {
      ans += l[i];
      sum -= l[i];
      if (sum < 0) {
        if (opw)
          ans -= sum * 3;
        else
          ans -= sum * 5;
        sum = 0;
      }
    }
    num = min(num, sum);
  }
  if (sum > 0) ans -= ((num << 1) + (sum - num));
  printf("%lld", ans);
  return 0;
}
