#include <bits/stdc++.h>
const int MAXN = 1e5 + 10;
int n;
long long a[MAXN];
char s[MAXN];
long long cnt[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i);
    a[i] *= 2;
  }
  scanf("%s", s + 1);
  int last = 1;
  long long ans = 0;
  long long len_lava = 0, len_grass = 0, len_water = 0;
  bool water = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'L')
      len_lava += a[i];
    else if (s[i] == 'G')
      len_grass += a[i];
    else
      len_water += a[i], water = 1;
    if (i == n || (s[i] == 'L' && s[i + 1] != 'L')) {
      if (len_grass + len_water < len_lava) {
        if (water) {
          ans += len_lava + len_grass * 5 + (len_lava - len_grass) * 3;
        } else {
          ans += len_lava + len_lava * 5;
        }
        len_water = len_lava = len_grass = 0;
        last = i + 1;
      }
    }
  }
  for (int i = n; i >= last; i--) {
    if (s[i] == 'L') {
      cnt[i] = cnt[i + 1] + a[i];
    } else {
      cnt[i] = cnt[i + 1] - a[i];
    }
    cnt[i] = std::max(cnt[i], 0ll);
  }
  long long val = 0;
  for (int i = last; i <= n; i++) {
    if (s[i] == 'G') {
      long long fly = (val + cnt[i + 1] + a[i]) / 2 - cnt[i + 1];
      if (fly < 0) throw;
      fly = std::min(fly, a[i]);
      val += a[i] - fly - fly;
      ans += (a[i] - fly) * 5 + fly;
    } else if (s[i] == 'W') {
      val += a[i];
      ans += a[i] * 3;
    } else {
      val -= a[i];
      ans += a[i];
    }
    if (val < 0) throw;
  }
  ans -= val;
  printf("%lld\n", ans / 2);
}
