#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::fixed;
using std::ios_base;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::nth_element;
using std::pair;
using std::queue;
using std::reverse;
using std::set;
using std::sort;
using std::stack;
using std::string;
using std::tuple;
using std::unordered_map;
using std::unordered_set;
using std::vector;
const int MAXN = 200005;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int64_t L_INF = 4e18;
int n;
int64_t l[MAXN], e[MAXN], d[MAXN];
char t[MAXN];
int64_t ans = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> l[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  bool was_water = false;
  int64_t extra = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i] != 'L') {
      was_water |= t[i] == 'W';
      extra += l[i];
      ans += (t[i] == 'W' ? 3 : 5) * l[i];
    } else {
      if (extra < l[i]) {
        ans += (was_water ? 3 : 5) * (l[i] - extra);
        extra = l[i];
      }
      ans += l[i];
      extra -= l[i];
    }
    e[i] = extra;
  }
  int64_t ming = e[n];
  for (int i = n; i > 0; i--) {
    if (t[i] == 'G') {
      d[i] = std::min(l[i] + std::min(e[i - 1], l[i]), ming);
    } else {
      d[i] = 0;
    }
    ming = std::min(ming, e[i]) - d[i];
    ans -= 2 * d[i];
  }
  for (int i = 1; i <= n; i++) {
    d[i] += d[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    e[i] -= d[i];
    d[i] = 0;
  }
  int64_t minw = e[n];
  for (int i = n; i > 0; i--) {
    if (t[i] == 'W') {
      d[i] = std::min(l[i] + std::min(e[i - 1], l[i]), minw);
    } else {
      d[i] = 0;
    }
    minw = std::min(minw, e[i]) - d[i];
    ans -= d[i];
  }
  cout << ans << '\n';
  return 0;
}
