#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) {
  return rng() % (y + 1 - x) + x;
}
string inline to_string(char c) {
  string second(1, c);
  return second;
}
template <typename T>
inline T gcd(T a, T b) {
  return a == 0 ? llabs(b) : gcd(b % a, a);
}
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using spi = pair<ll, pi>;
using dpi = pair<pi, pi>;
long long LLINF = 1e18;
int INF = 1e9 + 1e6;
struct node {
  int second, e, m;
  ll v, add;
  node *l, *r;
  node(int S, int E) {
    second = S, e = E, m = (second + e) >> 1;
    v = add = 0;
    if (second ^ e) l = new node(second, m), r = new node(m + 1, e);
  }
  void update(int x, int y, ll nval) {
    if (second == x && e == y) {
      add += nval;
      return;
    }
    if (x > m)
      r->update(x, y, nval);
    else if (y <= m)
      l->update(x, y, nval);
    else
      l->update(x, m, nval), r->update(m + 1, y, nval);
    v = min(l->value(), r->value());
  }
  ll rmq(int x, int y) {
    value();
    if (second == x && e == y) return v;
    if (x > m)
      return r->rmq(x, y);
    else if (y <= m)
      return l->rmq(x, y);
    else
      return min(l->rmq(x, m), r->rmq(m + 1, y));
  }
  ll value() {
    v += add;
    if (second ^ e) l->add += add, r->add += add;
    add = 0;
    return v;
  }
} * seg;
ll n, A[(100006)], ofs, ans;
string S;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (ll i = 1; i <= ll(n); ++i) cin >> A[i];
  cin >> S;
  S = '*' + S;
  seg = new node(1, n);
  ll water = -1;
  for (ll i = 1; i <= ll(n); ++i)
    if (S[i] == 'W') {
      if (water == -1) water = i;
      ofs += A[i];
      ans += 3 * A[i];
      seg->update(i, i, ofs);
    } else if (S[i] == 'G') {
      ofs += A[i];
      ans += 5 * A[i];
      seg->update(i, i, ofs);
    } else {
      ofs -= A[i];
      ans += A[i];
      if (ofs < 0) {
        if (water == -1) {
          ans += 5 * (-ofs);
          seg->update(1, i - 1, -ofs);
        } else {
          ans += 3 * (-ofs);
          seg->update(water, i - 1, -ofs);
        }
        ofs = 0;
      }
      seg->update(i, i, ofs);
    }
  for (ll i = n; i >= ll(1); --i)
    if (S[i] == 'G') {
      ll lol = seg->rmq(i, n);
      ans -= min(4 * lol / 2, 4 * A[i]);
      seg->update(i, n, -min(A[i] * 2, lol));
    }
  for (ll i = n; i >= ll(1); --i)
    if (S[i] == 'W') {
      ll lol = seg->rmq(i, n);
      ans -= min(2 * lol / 2, 2 * A[i]);
      seg->update(i, n, -min(A[i] * 2, lol));
    }
  cout << ans << '\n';
}
