#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> L(N);
  for (long long &l : L) cin >> l;
  string T;
  cin >> T;
  bool hadWater = false;
  long long time = 0, stamina = 0, twiceGrass = 0;
  for (int i = 0; i < N; ++i) {
    if (T[i] == 'L') {
      time += L[i];
      stamina -= L[i];
      if (stamina < 0) {
        time -= stamina * (hadWater ? 3 : 5);
        stamina = 0;
      }
    } else if (T[i] == 'W') {
      hadWater = true;
      stamina += L[i];
      time += 3 * L[i];
    } else {
      stamina += L[i];
      time += 5 * L[i];
      twiceGrass += 2 * L[i];
    }
    twiceGrass = min(twiceGrass, stamina);
  }
  if (stamina > 0) {
    time -= (5 - 1) * twiceGrass / 2;
    time -= (3 - 1) * (stamina - twiceGrass) / 2;
  }
  cout << time << endl;
}
