#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, min = 10000000000000, c = 0, FLAG = 0;
  cin >> n;
  long long a[n + 1];
  char s[n + 1];
  cin >> s;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    if ((s[i] == 'R') && (s[i + 1] == 'L')) {
      c = (a[i + 1] - a[i]) / 2;
      FLAG = 1;
      if (c < min) min = c;
    }
  }
  if (FLAG == 1)
    cout << min;
  else
    cout << "-1";
}
