#include <bits/stdc++.h>
using namespace std;
const int MX = 300005;
const int BLOCK = 105;
const long long inf = 8000000000000000069ll;
const long long mod = 1e9 + 7;
const long long inv2 = (mod + 1) / 2;
const int dxh[] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dyh[] = {2, -2, 2, -2, 1, -1, 1, -1};
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0};
const int dz[] = {0, 0, 0, 0, 1, -1};
const int dxd[] = {1, 1, 1, 0, -1, -1, -1, 0};
const int dyd[] = {1, 0, -1, -1, -1, 0, 1, 1};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  string s;
  cin >> s;
  long long stamina = 0ll, ans = 0ll, convert_grass = 0ll;
  bool water = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'G') {
      stamina += v[i];
      ans += 5ll * v[i];
      convert_grass += 2ll * v[i];
    } else if (s[i] == 'W') {
      stamina += v[i];
      ans += 3ll * v[i];
      water = 1;
    } else {
      ans += v[i];
      stamina -= v[i];
      if (stamina < 0) {
        if (water)
          ans -= 3ll * stamina;
        else
          ans -= 5ll * stamina;
        stamina = 0ll;
      }
    }
    convert_grass = min(convert_grass, stamina);
  }
  if (stamina > 0) ans -= stamina + convert_grass;
  cout << ans << endl;
  return 0;
}
