#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  string s;
  vector<long long> v;
  cin >> n;
  cin >> s;
  int z;
  for (long long i = 0; i < n; i++) {
    cin >> z;
    v.push_back(z);
  }
  bool col = false;
  vector<int> diff;
  int x;
  int ind = find(v.begin(), v.end(), 'R') - v.end();
  for (long long i = ind; i < n - 1; i++) {
    if (s[i] == 'R') {
      if (s[i + 1] == 'L') {
        x = abs(v[i] - v[i + 1]) / 2;
        diff.push_back(x);
        col = true;
      }
    }
  }
  if (col == false)
    cout << "-1" << endl;
  else
    cout << *min_element(diff.begin(), diff.end());
  return 0;
}
