#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int arr[2000002];
bool ok;
int ans = INT_MAX, last, cur;
int main() {
  cin >> n;
  cin >> s;
  cin >> last;
  for (int i = 1; i < n; i++) {
    cin >> cur;
    if (s[i] == 'L' and s[i - 1] == 'R') {
      ans = min(ans, (cur - last) / 2);
      ok = 1;
    }
    last = cur;
  }
  if (ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
