#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int A[200555];
int rs = 2e9 + 69;
void read() {
  cin >> n;
  cin >> s;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      rs = min(rs, (A[i + 2] - A[i + 1]) / 2);
    }
  }
  if (rs == 2e9 + 69)
    cout << -1;
  else
    cout << rs;
  return;
}
int main() {
  read();
  return 0;
}
