#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<long long> pos(n);
  for (long long i = 0; i < n; i++) cin >> pos[i];
  long long ans = 1e12;
  bool found = 0;
  for (long long i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      ans = min(pos[i + 1] - pos[i], ans);
      found = 1;
    }
  }
  cout << (found ? ans / 2 : -1) << "\n";
  return 0;
}
