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