#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n;
long long l[100000];
char t[100000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> l[i];
  for (int i = 0; i < (n); i++) cin >> t[i];
  long long res = 0, stam = 0, doubleGrass = 0;
  bool foundWater = 0;
  for (int i = 0; i < (n); i++) {
    if (t[i] == 'W') {
      foundWater = 1;
      res += 3 * l[i];
      stam += l[i];
    } else if (t[i] == 'G') {
      res += 5 * l[i];
      stam += l[i];
      doubleGrass += 2 * l[i];
    } else {
      res += l[i];
      stam -= l[i];
      if (stam < 0) {
        res -= (foundWater ? 3 : 5) * stam;
        stam = 0;
      }
    }
    doubleGrass = min(doubleGrass, stam);
  }
  res -= 2 * doubleGrass;
  res -= (stam - doubleGrass);
  cout << res << endl;
}
