#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int a[n], i, j, k, cnt = 1e9, tmp = 0;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      tmp = (a[i + 1] - a[i]) / 2;
      if (tmp < cnt) cnt = tmp;
    }
  }
  if (cnt == 1e9)
    cout << -1 << endl;
  else
    cout << cnt << endl;
  return 0;
}
