#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int inf = 1e9;
int mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long int L[n];
  for (int i = 0; i < n; i++) {
    cin >> L[i];
  }
  string type;
  cin >> type;
  long long int excess_grass = 0, stamina = 0, total = 0;
  bool water = false;
  for (int i = 0; i < n; i++) {
    if (type[i] == 'L') {
      total += L[i];
      if (stamina < L[i]) {
        if (water) {
          total += (L[i] - stamina) * 3;
        } else {
          total += (L[i] - stamina) * 5;
        }
        stamina = L[i];
      }
      stamina -= L[i];
    } else if (type[i] == 'W') {
      stamina += L[i];
      total += 3 * L[i];
      water = true;
    } else {
      total += 5 * L[i];
      stamina += L[i];
      excess_grass += 2 * L[i];
    }
    excess_grass = min(excess_grass, stamina);
  }
  if (stamina) {
    total -= 2 * excess_grass;
    total -= (stamina - excess_grass);
  }
  cout << total << "\n";
  return 0;
}
