#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    char str[200005];
    scanf("%s", str);
    int pos = 0;
    int r = -1;
    bool rf = false;
    bool lf = false;
    int ans = (1 << 30);
    for (int i = 0; i < n; i++) {
      int x;
      scanf("%d", &x);
      x = x >> 1;
      if (str[i] == 'R') {
        rf = true;
        r = x;
      } else {
        if (!rf)
          continue;
        else {
          lf = true;
          ans = min(ans, x - r);
        }
      }
    }
    if (!lf) ans = -1;
    cout << ans << endl;
  }
  return 0;
}
