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