#include <bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  string s;
  cin >> s;
  ll wg, ww;
  wg = ww = 0;
  ll e = 0;
  ll ans = 0;
  bool was_w = 0;
  vector<ll> tos;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'L') {
      if (arr[i] <= e) {
        e -= arr[i];
        ans += arr[i];
        ww = wg = 0;
      } else {
        e -= arr[i];
        ans += arr[i];
        if (was_w) {
          ans -= e * 3;
        } else {
          ans -= e * 5;
        }
        e = 0;
        ww = wg = 0;
      }
      tos.push_back(e);
      continue;
    }
    if (s[i] == 'W') {
      was_w = 1;
      ans += arr[i] * 3;
      ww += arr[i];
      e += arr[i];
      tos.push_back(e);
      continue;
    }
    if (s[i] == 'G') {
      ans += arr[i] * 5;
      wg += arr[i];
      e += arr[i];
      tos.push_back(e);
      continue;
    }
  }
  for (int i = tos.size() - 2; i >= 0; --i) tos[i] = min(tos[i], tos[i + 1]);
  ll mi = 0;
  for (int i = 0; i < n; ++i) {
    tos[i] -= mi;
    if (s[i] == 'G') {
      if (arr[i] * 2 <= tos[i]) {
        ans -= arr[i] * 4;
        tos[i] -= arr[i] * 2;
        mi += arr[i] * 2;
      } else {
        mi += tos[i];
        ans -= tos[i] * 2;
        tos[i] = 0;
      }
    }
  }
  for (int i = tos.size() - 2; i >= 0; --i) tos[i] = min(tos[i], tos[i + 1]);
  mi = 0;
  for (int i = 0; i < n; ++i) {
    tos[i] -= mi;
    if (s[i] == 'W') {
      if (arr[i] * 2 <= tos[i]) {
        tos[i] -= arr[i] * 2;
        mi += arr[i] * 2;
        ans -= arr[i] * 2;
      } else {
        mi += tos[i];
        ans -= tos[i];
        tos[i] = 0;
      }
    }
  }
  cout << ans;
  return 0;
}
