#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, ans = 1e9 + 1;
  string s;
  cin >> n >> s;
  vector<double> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    if (i < n + 1 && s[i] == 'R' && s[i + 1] == 'L' &&
        (x[i + 1] - x[i]) / 2 < ans) {
      ans = (x[i + 1] - x[i]) / 2;
    }
  }
  if (ans == 1e9 + 1) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}
