#include <bits/stdc++.h>
using namespace std;
long long fG, fW;
bool sG, sW;
long long tot;
int N;
long long L[1 << 17];
char S[1 << 17];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%lld", L + i);
  scanf("%s", S);
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'G') {
      sG = 1;
      long long mn = min(fW, L[i]);
      L[i] -= mn;
      fW -= mn;
      fG += 2 * mn;
      tot += 2 * mn;
      tot += 3 * L[i];
      fG += L[i];
    } else if (S[i] == 'W') {
      sW = 1;
      tot += 2 * L[i];
      fW += L[i];
    } else {
      long long mn = min(fW, L[i]);
      L[i] -= mn;
      fW -= mn;
      tot += 2 * mn;
      mn = min(fG, L[i]);
      L[i] -= mn;
      fG -= mn;
      tot += 3 * mn;
      if (sW) {
        tot += 4 * L[i];
        L[i] = 0;
      }
      if (sG) {
        tot += 6 * L[i];
        L[i] = 0;
      }
    }
  }
  printf("%lld\n", tot);
}
