#include <bits/stdc++.h>
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  bool ok = false;
  multiset<int> m;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L' && (v[i + 1] - v[i]) % 2 == 0) {
      m.insert((v[i + 1] - v[i]) / 2);
      ok = true;
    }
  }
  if (ok == false) {
    cout << -1;
  } else {
    multiset<int>::iterator it = m.begin();
    cout << *it;
  }
  return 0;
}
