#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
long long best = 5;
long long ans;
deque<int> w, g;
long long l[N];
char s[N];
void cost(long long& a, long long& b, long long c) {
  long long cur = min(a, b);
  a -= cur;
  b -= cur;
  ans += cur * c;
}
void cost(long long& a, deque<int>& q, long long c, bool f) {
  while (!q.empty() && a) {
    int i = f ? q.front() : q.back();
    long long cur = min(a, l[i]);
    l[i] -= cur;
    a -= cur;
    ans += cur * c;
    if (l[i] == 0) f ? q.pop_front() : q.pop_back();
  }
}
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 <= n; ++i)
    if (s[i] == 'L') {
      cost(l[i], w, 4, true);
      cost(l[i], g, 6, false);
      cost(l[i], g, 6, false);
      ans += l[i] * (best + 1);
    } else if (s[i] == 'W') {
      best = 3;
      w.push_front(i);
    } else {
      g.push_front(i);
    }
  long long wsum = 0, gs = 0;
  for (int i = 1; i <= n; ++i)
    if (s[i] == 'W')
      wsum += l[i];
    else if (s[i] == 'G') {
      cost(l[i], wsum, 4);
      gs += l[i];
    }
  ans += wsum * 2 + gs * 3;
  printf("%lld\n", ans);
  return 0;
}
