#include <bits/stdc++.h>
using namespace std;
long long int ar[500009], br[500009];
int main() {
  long long int a, b, c, i, j = 0, k = 9999999999999;
  string s;
  cin >> a;
  getchar();
  cin >> s;
  for (i = 0; i < a; i++) {
    cin >> ar[i];
  }
  for (i = 0; i < a - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      k = min(k, (ar[i + 1] - ar[i]));
    }
  }
  if (k == 9999999999999) {
    cout << "-1";
  } else
    cout << (k / 2) << endl;
}
