#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
char S[N];
long long a[N], sum, now, g, w, x;
int n;
template <class I>
inline I Min(I p, I q) {
  return p < q ? p : q;
}
int main() {
  scanf("%d", &n);
  register int i;
  for (i = 1; i <= n; ++i) scanf("%lld", &a[i]), a[i] <<= 1, sum += a[i];
  scanf("%s", S + 1);
  register int mn = 5;
  for (i = 1; i <= n; ++i)
    g += (S[i] == 'G' ? a[i] : 0), w += (S[i] == 'W' ? mn = 3, a[i] : 0),
        now = a[i], x = Min(now >> 1, w), sum += (x << 1), now -= (x << 1),
        w -= x, x = Min(now >> 1, g), sum += (x << 2), now -= (x << 1), g -= x,
        sum += mn * now;
  printf("%lld", sum >> 1);
  return 0;
}
