#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  string a;
  cin >> a;
  int Arr[N];
  for (int i = 0; i < N; i++) {
    cin >> Arr[i];
  }
  int R = 10000000009;
  bool done = false;
  for (int i = 0; i < N; i++) {
    if (a[i] == 'R' && a[i + 1] == 'L') {
      R = min(R, (Arr[i + 1] - Arr[i]) / 2);
      done = true;
    }
  }
  if (done) {
    cout << R;
  } else {
    cout << -1;
  }
  return 0;
}
