#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string rl;
  cin >> rl;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) cin >> A[i];
  int diff = 2147483647;
  int t;
  for (int i = 0; i < n - 1; i++)
    if (rl[i] == 'R' && rl[i + 1] == 'L') {
      t = (A[i + 1] - A[i]) / 2;
      diff = min(diff, t);
    }
  if (diff == 2147483647) diff = -1;
  cout << diff << "\n";
  return 0;
}
