#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> len(n);
  string types;
  for (auto &i : len) cin >> i;
  cin >> types;
  bool water_tag = 0;
  long long grass = 0, points = 0, time = 0;
  for (long long i = 0; i < n; i++) {
    if (types[i] == 'L') {
      points -= len[i];
      time += len[i];
      if (points < 0) {
        time += -1 * points * (water_tag ? 3 : 5);
        points = 0;
      }
    } else if (types[i] == 'W') {
      water_tag = 1;
      time += len[i] * 3;
      points += len[i];
    } else {
      grass += 2 * len[i];
      time += 5 * len[i];
      points += len[i];
    }
    grass = min(grass, points);
  }
  if (points > 0) {
    time -= 2 * grass;
    time -= (points - grass);
  }
  cout << time;
  return 0;
}
