#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
int main() {
  int n;
  string ss;
  vector<int> L, R;
  cin >> n >> ss;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (ss[i] == 'R')
      R.push_back(a[i]);
    else
      L.push_back(a[i]);
  }
  int minn = 0x3f3f3f3f;
  for (int i = 0; i < R.size(); i++) {
    auto it = lower_bound(L.begin(), L.end(), R[i]);
    if (it == L.end())
      continue;
    else {
      minn = min(minn, (*it - R[i]) / 2);
    }
  }
  if (minn == 0x3f3f3f3f) minn = -1;
  cout << minn << endl;
  return 0;
}
