#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  string s;
  cin >> n >> s;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  long long res = 19999999999;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      long long r = (v[i + 1] - v[i]) / 2;
      if (r < res) res = r;
    }
  }
  if (res == 19999999999)
    cout << "-1" << endl;
  else
    cout << res << endl;
  return 0;
}
