#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int n, fis1, fis2;
long long f[N], sum, ans;
char s[N];
stack<int> q1, q2;
void twork() {
  for (int i = 1, iE = n; i <= iE; i++) {
    if (s[i] == 'G')
      q1.push(i);
    else if (s[i] == 'W')
      q2.push(i);
    else {
      while (!q2.empty() && f[i]) {
        if (f[q2.top()] > f[i])
          ans += f[i] * 4, f[q2.top()] -= f[i], f[i] = 0;
        else
          ans += f[q2.top()] * 4, f[i] -= f[q2.top()], f[q2.top()] = 0,
                                                       q2.pop();
      }
      while (!q1.empty() && f[i]) {
        if (f[q1.top()] > f[i])
          ans += f[i] * 6, f[q1.top()] -= f[i], f[i] = 0;
        else
          ans += f[q1.top()] * 6, f[i] -= f[q1.top()], f[q1.top()] = 0,
                                                       q1.pop();
      }
      assert(!f[i]);
    }
  }
  while (!q1.empty()) q1.pop();
  while (!q2.empty()) q2.pop();
}
void Main() {
  scanf("%d", &n);
  for (int i = 1, iE = n; i <= iE; i++) scanf("%lld", &f[i]);
  scanf("%s", s + 1);
  for (int i = 1, iE = n; i <= iE; i++) {
    if (s[i] == 'G') {
      if (!fis1) fis1 = i;
      sum += f[i];
    } else if (s[i] == 'W') {
      if (!fis2) fis2 = i;
      sum += f[i];
    } else {
      if (sum < f[i]) {
        if (fis2)
          f[fis2] += f[i] - sum;
        else
          f[fis1] += f[i] - sum;
        sum = f[i];
      }
      sum -= f[i];
    }
  }
  twork();
  for (int i = 1, iE = n; i <= iE; i++) {
    if (s[i] == 'W')
      q2.push(i);
    else if (s[i] == 'G') {
      while (!q2.empty() && f[i]) {
        if (f[i] > f[q2.top()])
          ans += 4 * f[q2.top()], f[i] -= f[q2.top()], f[q2.top()] = 0,
                                                       q2.pop();
        else
          ans += 4 * f[i], f[q2.top()] -= f[i], f[i] = 0;
      }
      ans += 3 * f[i], f[i] = 0;
    }
  }
  for (int i = 1, iE = n; i <= iE; i++)
    if (s[i] == 'W') ans += 2 * f[i];
  printf("%lld\n", ans);
}
int main() {
  Main();
  return 0;
}
