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