#include <bits/stdc++.h>
using namespace std;
long long gi() {
  long long x = 0, w = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') w = 0, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return w ? x : -x;
}
const int N = 1e5 + 5;
int n, fg;
char s[N];
long long a[N], G, S, ans;
int main() {
  n = gi();
  for (int i = 1; i <= n; ++i) a[i] = gi();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'G') ans += a[i] * 5, S += a[i], G += a[i] * 2;
    if (s[i] == 'W') ans += a[i] * 3, S += a[i], fg = 1;
    if (s[i] == 'L') {
      ans += a[i], S -= a[i];
      if (S < 0) ans -= S * (fg ? 3 : 5), S = 0;
    }
    G = min(G, S);
  }
  printf("%lld\n", ans - S - G);
  return 0;
}
