#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, used_to_swim = 0, used_to_walk = 0;
long long l[N], now = 0, tim = 0;
long long energy_change[N], pref[N];
char opt[N];
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &l[i]);
  }
  scanf("%s", opt + 1);
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    if (opt[i] == 'G') {
      if (!used_to_walk) used_to_walk = i;
      energy_change[i] += l[i];
      now += l[i];
      tim += 5 * l[i];
    } else if (opt[i] == 'W') {
      if (!used_to_swim) used_to_swim = i;
      energy_change[i] += l[i];
      now += l[i];
      tim += 3 * l[i];
    } else {
      now -= l[i];
      tim += l[i];
      energy_change[i] -= l[i];
      if (now < 0) {
        if (used_to_swim) {
          tim += 3 * (-now);
          energy_change[used_to_swim] += (-now);
        } else {
          tim += 5 * (-now);
          energy_change[used_to_walk] += (-now);
        }
        now = 0;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    pref[i] = pref[i - 1] + energy_change[i];
  }
  long long mi_energy = 1e18;
  for (int i = n; i >= 1; --i) {
    mi_energy = min(mi_energy, pref[i]);
    if (opt[i] != 'G') continue;
    long long res = min(mi_energy, energy_change[i] * 2);
    tim -= res * (5 - 1) / 2;
    mi_energy -= res;
    energy_change[i] -= res;
  }
  for (int i = 1; i <= n; ++i) {
    pref[i] = pref[i - 1] + energy_change[i];
  }
  mi_energy = 1e18;
  for (int i = n; i >= 1; --i) {
    mi_energy = min(mi_energy, pref[i]);
    if (opt[i] != 'W') continue;
    long long res = min(mi_energy, energy_change[i] * 2);
    tim -= res * (3 - 1) / 2;
    mi_energy -= res;
    energy_change[i] -= res;
  }
  printf("%lld\n", tim);
}
int main() {
  init();
  solve();
  return 0;
}
