#include <bits/stdc++.h>
using namespace std;
const int maxn = 100003;
int n;
long long lg2, lw2, Time, E, a[maxn];
bool eg, ew;
char s[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    E -= a[i];
    Time += a[i];
    if (s[i] == 'G') {
      lg2 += a[i] * 2;
      eg = 1;
    } else if (s[i] == 'W') {
      lw2 += a[i] * 2;
      ew = 1;
    }
    if (E < 0) {
      if (lw2 >= -E) {
        Time += -E;
        lw2 -= -E;
        E = 0;
      } else {
        Time += lw2;
        E += lw2;
        lw2 = 0;
        if (lg2 >= -E) {
          Time += -E * 2;
          lg2 -= -E;
          E = 0;
        } else {
          Time += lg2 * 2;
          E += lg2;
          lg2 = 0;
          if (E < 0) {
            if (ew) {
              Time += -E * 3;
              E = 0;
            } else if (eg) {
              Time += -E * 5;
              E = 0;
            }
          }
        }
      }
    }
  }
  printf("%lld\n", Time);
  return 0;
}
