#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<long long> v(n);
  for (long long i = 0; i <= n - 1; i++) cin >> v[i];
  long long ans = mod;
  for (long long i = 0; i <= n - 2; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') ans = min(ans, abs(v[i] - v[i + 1]));
  }
  if (ans == mod)
    cout << -1;
  else
    cout << ans / 2;
}
int main() {
  long long tc = 1;
  while (tc--) {
    solve();
  }
}
