#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> num(n);
  for (auto &x : num) cin >> x;
  int flag = 0;
  int t, res, min = 1e9;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      flag = 1;
      t = (num[i + 1] - num[i]) / 2;
      res = ceil(t);
      if (res < min) min = res;
    }
  }
  if (flag == 0)
    cout << -1 << endl;
  else
    cout << min << endl;
  cerr << "Time taken : " << (float)clock() / CLOCKS_PER_SEC << " sec" << endl;
  ;
  return 0;
}
