#include <bits/stdc++.h>
using namespace std;
constexpr int64_t inf = numeric_limits<int64_t>::max() / 2;
int64_t truncAdd(int64_t a, int64_t b) {
  int64_t c = a + b;
  if (c > inf) {
    c = inf;
  }
  return c;
}
struct PWL {
  int64_t slopeStarts[6];
  int64_t yIntercept;
  friend ostream& operator<<(ostream& o, PWL& f);
  void insertSlope(int s, int64_t len) {
    for (s++; s < 6; s++) {
      slopeStarts[s] = truncAdd(slopeStarts[s], len);
    }
  }
  void shift(int64_t amt) {
    for (int s = 0; s < 6; s++) {
      slopeStarts[s] += amt;
    }
    int64_t y = yIntercept;
    for (int s = 1; s < 6; s++) {
      if (s == 5 || slopeStarts[s + 1] > 0) {
        y += (-slopeStarts[s]) * s;
        break;
      }
      y += (slopeStarts[s + 1] - slopeStarts[s]) * s;
    }
    yIntercept = y;
    for (int s = 1; s < 6; s++) {
      if (slopeStarts[s] < 0) slopeStarts[s] = 0;
    }
  }
  PWL() : slopeStarts{0, 0, 0, 0, 0, 0}, yIntercept(0) {}
};
void advance(PWL& f, char t, int64_t len) {
  if (t == 'G' || t == 'W') {
    int c = (t == 'G' ? 4 : 2);
    f.insertSlope(c / 2, len * 2);
    c++;
    f.insertSlope(c, inf);
  }
  f.shift(-len);
  f.yIntercept += len;
}
int main() {
  int n;
  cin >> n;
  vector<int64_t> lens(n);
  for (int i = 0; i < n; i++) {
    cin >> lens[i];
  }
  string terrains;
  cin >> terrains;
  PWL f;
  for (int i = 0; i < n; i++) {
    advance(f, terrains[i], lens[i]);
  }
  cout << f.yIntercept << endl;
  return 0;
}
