#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  long long n;
  cin >> n;
  string a;
  cin >> a;
  long long arr[n];
  for (long long i = 0; i < (n); i++) cin >> arr[i];
  long long ans = LLONG_MAX;
  bool c = true;
  for (long long i = 0; i < (n - 1); i++) {
    if (a[i] == 'R' && a[i + 1] == 'L') {
      ans = min(ans, (arr[i + 1] - arr[i]) / 2);
      c = false;
    }
  }
  if (c)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
