#include <bits/stdc++.h>
using namespace std;
long long n, arr[100001];
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cin >> s;
  bool gotwater = false;
  long long curt = 0, energy = 0, totwalk = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') {
      curt += arr[i];
      if (energy < arr[i]) {
        long long diff = arr[i] - energy;
        if (gotwater)
          curt += diff * 3;
        else
          curt += diff * 5;
        energy += diff;
      }
      energy -= arr[i];
    } else {
      energy += arr[i];
      if (s[i] == 'W') {
        gotwater = true;
        curt += arr[i] * 3;
      } else {
        curt += arr[i] * 5;
        totwalk += arr[i] * 2;
      }
    }
    totwalk = min(totwalk, energy);
  }
  if (energy > 0) {
    curt -= totwalk * 2;
    curt -= (energy - totwalk);
  }
  cout << curt;
}
