#include <bits/stdc++.h>
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
const int N = 1e5 + 500;
long long n, len1, len2, ans, nwv = 1e9;
long long l[N];
char s[N];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(l[i]);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    ans += l[i];
    if (s[i] == 'G') {
      len2 += l[i] << 1;
      nwv = min(nwv, 5ll);
    } else if (s[i] == 'W') {
      len1 += l[i] << 1;
      nwv = min(nwv, 3ll);
    }
    long long x = l[i];
    long long y = min(x, len1);
    ans += y;
    x -= y;
    len1 -= y;
    y = min(x, len2);
    ans += y << 1;
    x -= y;
    len2 -= y;
    ans += x * nwv;
  }
  printf("%lld\n", ans);
  return 0;
}
