#include <bits/stdc++.h>
using namespace std;
int n;
long long l[110000];
char S[110000];
struct A {
  long long l[6];
  long long aa;
  A() {
    aa = 0;
    memset(l, 0, sizeof l);
  }
  void deduce(long long xx) {
    for (int i = 1; i <= 5; i++) {
      long long d = min(xx, l[i]);
      aa += d * i;
      l[i] -= d;
      xx -= d;
    }
  }
} now;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &l[i]);
  scanf("%s", S + 1);
  for (int i = 1; i <= 4; i++) now.l[i] = 0;
  now.l[5] = 1e18;
  for (int i = 1; i <= n; i++) {
    if (S[i] == 'G') {
      now.l[2] += 2 * l[i];
      now.aa += l[i];
      now.deduce(l[i]);
    } else if (S[i] == 'W') {
      now.l[1] += 2 * l[i];
      now.l[3] = 1e18;
      now.aa += l[i];
      now.deduce(l[i]);
    } else if (S[i] == 'L') {
      now.aa += l[i];
      now.deduce(l[i]);
    }
  }
  cout << now.aa << endl;
}
