#include <bits/stdc++.h>
using namespace std;
long long l[100005];
char S[100005];
int main() {
  long long n, s = 0, G = 0, W = 0, mn = 5;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> l[i], l[i] *= 2, s += l[i];
  scanf("%s", S + 1);
  for (long long i = 1; i <= n; i++) {
    if (S[i] == 'G') G += l[i];
    if (S[i] == 'W') W += l[i], mn = 3;
    long long t = l[i], e;
    e = min(t / 2, W), s += e * 2, t -= e * 2, W -= e;
    e = min(t / 2, G), s += e * 4, t -= e * 2, G -= e;
    s += mn * t;
  }
  cout << s / 2;
  return 0;
}
