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