#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int number, Min = 1000000000, f, s;
  cin >> number >> str >> f;
  for (int c = 1; c < number; c++) {
    cin >> s;
    if (str[c] == 'L' && str[c - 1] == 'R') Min = min(Min, (s - f) / 2);
    f = s;
  }
  cout << (Min < 1000000000 ? Min : -1);
}
