#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, min_t = -1;
  int n;
  long long int pos1, pos2;
  scanf("%d", &n);
  char a[n];
  scanf("%s", &a);
  cin >> pos1;
  for (int i = 1; i < n; i++) {
    cin >> pos2;
    if (a[i - 1] == 'R' && a[i] == 'L') {
      t = (pos2 - pos1) / 2.0;
      if (min_t == -1) {
        min_t = t;
      } else {
        if (min_t > t) min_t = t;
      }
    }
    pos1 = pos2;
  }
  cout << min_t << endl;
  return 0;
}
