#include <bits/stdc++.h>
using namespace std;
long long a[100010], sm[100010], ned[100010], beter[100010];
char s[100010];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      scanf("%lld", a + i);
    }
    scanf("%s", s);
    ned[n - 1] = beter[n - 1] = sm[n - 1] = 0;
    for (int i = n - 2; i >= 0; --i) {
      ned[i] = ned[i + 1];
      beter[i] = beter[i + 1];
      if (s[i + 1] == 'L') {
        ned[i] += a[i + 1];
      } else if (s[i + 1] == 'G') {
        beter[i] += a[i + 1];
      } else {
        ned[i] = max(0ll, ned[i] - a[i + 1]);
      }
    }
    long long ans = 0;
    long long pwr = 0;
    bool l = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'G') {
        if (ned[i] <= pwr) {
          ans += min(a[i], (pwr - ned[i]));
          ans += 3 * (a[i] - min(a[i], (pwr - ned[i])));
          pwr -= min(a[i], (pwr - ned[i]));
        } else if (a[i] >= ned[i] - pwr) {
          ans += 5 * (ned[i] - pwr);
          ans += 3 * (a[i] - (ned[i] - pwr));
          pwr = ned[i];
        } else {
          ans += 5 * a[i];
          pwr += a[i];
        }
      } else if (s[i] == 'W') {
        l = 1;
        if (ned[i] <= pwr) {
          if (beter[i] + ned[i] <= pwr) {
            ans += min(a[i], pwr - ned[i] - beter[i]);
            ans += 2 * (a[i] - min(a[i], pwr - ned[i] - beter[i]));
            pwr -= min(a[i], pwr - ned[i] - beter[i]);
          } else {
            if (a[i] >= beter[i] + ned[i] - pwr) {
              ans += 3 * (beter[i] + ned[i] - pwr);
              ans += 2 * (a[i] - (beter[i] + ned[i] - pwr));
              pwr = beter[i] + ned[i];
            } else {
              ans += 3 * a[i];
              pwr += a[i];
            }
          }
        } else {
          if (a[i] >= beter[i] + ned[i] - pwr) {
            ans += 3 * (beter[i] + ned[i] - pwr);
            ans += 2 * (a[i] - (beter[i] + ned[i] - pwr));
            pwr = beter[i] + ned[i];
          } else {
            ans += 3 * a[i];
            pwr += a[i];
          }
        }
      } else {
        ans += a[i];
        if (pwr >= a[i]) {
          pwr -= a[i];
        } else {
          a[i] -= pwr;
          pwr = 0;
          if (l) {
            ans += a[i] * 3;
          } else {
            ans += a[i] * 5;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
