#include <bits/stdc++.h>
using namespace std;
int const INF = (int)1e9 + 1e3;
long long const INFL = (long long)1e18 + 1e6;
mt19937 tw(9450189);
uniform_int_distribution<long long> ll_distr;
long long rnd(long long a, long long b) {
  return ll_distr(tw) % (b - a + 1) + a;
}
void solve() {
  int n;
  cin >> n;
  vector<long long> arr;
  for (int i = 0; i < n; ++i) {
    long long l;
    cin >> l;
    arr.push_back(l);
  }
  string s;
  cin >> s;
  vector<pair<long long, long long> > poly;
  pair<long long, long long> from = {0, 0};
  if (s[0] == 'G') {
    poly.push_back({0, 5});
  } else {
    poly.push_back({0, 3});
  }
  function<void(int, long long)> add_seg = [&](int coef, long long len) {
    for (int j = 0; j < ((int)poly.size()); ++j) {
      if (poly[j].second == coef) {
        for (int k = j + 1; k < ((int)poly.size()); ++k) {
          poly[k].first += len;
        }
        return;
      } else if (poly[j].second > coef) {
        long long mem = poly[j].first;
        for (int k = j; k < ((int)poly.size()); ++k) {
          poly[k].first += len;
        }
        poly.insert(poly.begin() + j, {mem, coef});
        return;
      }
    }
  };
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'G') {
      pair<long long, long long> shift = {-arr[i], arr[i]};
      pair<long long, long long> seg = {arr[i] * 2, arr[i] * 4};
      from.first += shift.first;
      from.second += shift.second;
      add_seg(2, seg.first);
      long long last = INFL * 5;
      while (((int)poly.size()) && poly.back().second > 5) {
        last = poly.back().first;
        poly.pop_back();
      }
      if (!((int)poly.size()) ||
          (poly.back().second != 5 && last != INFL * 5)) {
        poly.push_back({last, 5});
      }
    } else if (s[i] == 'W') {
      pair<long long, long long> shift = {-arr[i], arr[i]};
      pair<long long, long long> seg = {arr[i] * 2, arr[i] * 2};
      from.first += shift.first;
      from.second += shift.second;
      add_seg(1, seg.first);
      long long last = INFL * 5;
      while (((int)poly.size()) && poly.back().second > 3) {
        last = poly.back().first;
        poly.pop_back();
      }
      if (!((int)poly.size()) ||
          (poly.back().second != 3 && last != INFL * 5)) {
        poly.push_back({last, 3});
      }
    } else {
      from.first -= arr[i];
      from.second += arr[i];
    }
    vector<pair<long long, long long> > next;
    pair<long long, long long> next_from;
    for (int i = 0; i < ((int)poly.size()); ++i) {
      if (from.first >= 0) {
        next.push_back({from.first, poly[i].second});
        if (i < ((int)poly.size()) - 1) {
          from.first += poly[i + 1].first - poly[i].first;
        }
      } else {
        if (i == ((int)poly.size()) - 1) {
          next_from = {0, from.second + (-from.first) * poly[i].second};
          next.push_back({0, poly[i].second});
        } else {
          if (from.first + (poly[i + 1].first - poly[i].first) < 0) {
            from.first += poly[i + 1].first - poly[i].first;
            from.second += (poly[i + 1].first - poly[i].first) * poly[i].second;
          } else {
            next_from = {0, from.second + (-from.first) * poly[i].second};
            next.push_back({0, poly[i].second});
            from.first += poly[i + 1].first - poly[i].first;
            from.second += (poly[i + 1].first - poly[i].first) * poly[i].second;
          }
        }
      }
    }
    swap(from, next_from);
    swap(poly, next);
  }
  for (int i = 0; i < ((int)poly.size()); ++i) {
    if (i == ((int)poly.size()) - 1 ||
        from.first + (poly[i + 1].first - poly[i].first) > 0) {
      cout << from.second + poly[i].second * (-from.first) << "\n";
      return;
    } else {
      from.second += poly[i].second * (poly[i + 1].first - poly[i].first);
      from.first += poly[i + 1].first - poly[i].first;
    }
  }
}
int main() {
  cout << setprecision(15) << fixed;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_count = 1;
  for (int test = 1; test <= test_count; ++test) {
    solve();
  }
}
