#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> L(n);
  long long ret = 0;
  for (int i = 0; i < n; i++) {
    cin >> L[i];
    ret += L[i];
  }
  string s;
  cin >> s;
  long long staminaW = 0, staminaG = 0;
  int mn = 5;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') {
      staminaW += L[i];
      ret += L[i];
      mn = 3;
    }
    if (s[i] == 'G') {
      long long left = L[i];
      long long fromW = min(staminaW, left);
      left -= fromW;
      staminaW -= fromW;
      staminaG += 2LL * fromW + left;
      ret += fromW + 2LL * left;
    }
    if (s[i] == 'L') {
      long long left = L[i];
      long long fromW = min(staminaW, left);
      left -= fromW;
      staminaW -= fromW;
      long long fromG = min(staminaG, left);
      left -= fromG;
      staminaG -= fromG;
      ret += fromW + 2LL * fromG + 1LL * mn * left;
    }
  }
  cout << ret << "\n";
  return 0;
}
