#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  string s;
  cin >> n >> s;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  size_t found = s.find("RL");
  if (found == string::npos) {
    cout << -1;
    return 0;
  }
  long long t = 1 + 1e9;
  while (found != string::npos) {
    t = min(t, (a[found + 1] - a[found]) / 2);
    found = s.find("RL", found + 1);
  }
  cout << t;
  return 0;
}
