#include <bits/stdc++.h>
using namespace std;
string str;
long long n, grass, water, lava, stamina, temp, ans, active, arr[100069];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cin >> str;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'G') {
      grass += arr[i], temp += arr[i] * 2, stamina += arr[i];
    } else if (str[i] == 'W') {
      water += arr[i], stamina += arr[i], active = 1;
    } else if (str[i] == 'L') {
      lava += arr[i], stamina -= arr[i];
      if (stamina < 0) {
        if (active)
          ans -= stamina * 3;
        else
          ans -= stamina * 5;
        stamina = 0;
      }
    }
    if (temp > stamina) temp = stamina;
  }
  ans += grass * 5 + water * 3 + lava;
  if (stamina > 0) ans -= temp * 2, ans -= (stamina - temp);
  cout << ans << endl;
}
