#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = 1e18;
const long long MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n;
  cin >> n;
  vector<long long> l(n);
  for (int i = 0; i < (n); i++) {
    cin >> l[i];
  }
  string s;
  cin >> s;
  vector<long long> amari(n + 1);
  vector<long long> mudag(n + 1);
  bool w = false;
  long long sta = 0;
  long long t = 0;
  for (int i = 0; i < (n); i++) {
    if (s[i] == 'G') {
      t += l[i] * 5;
      sta += l[i];
    } else if (s[i] == 'W') {
      w = true;
      t += l[i] * 3;
      sta += l[i];
    } else {
      if (sta >= l[i]) {
        t += l[i];
        sta -= l[i];
      } else {
        if (w) {
          t += (l[i] - sta) * 3;
        } else {
          t += (l[i] - sta) * 5;
        }
        t += l[i];
        sta = 0;
      }
    }
    amari[i + 1] = sta;
  }
  for (int i = n - 1; i >= 0; i--) {
    amari[i] = min(amari[i], amari[i + 1]);
  }
  long long use = amari[n];
  long long used = 0;
  for (int i = 0; i < (n); i++) {
    if (s[i] == 'G' && amari[i + 1] - used > 0 && use > 0) {
      long long temp = min(amari[i + 1] - used, use);
      if (2 * l[i] >= temp) {
        temp = temp;
      } else {
        temp = 2 * l[i];
      }
      used += temp;
      use -= temp;
      t -= 2 * temp;
    }
    amari[i + 1] -= used;
  }
  if (use > 0) {
    t -= use;
  }
  cout << t << endl;
}
