#include <bits/stdc++.h>
using namespace std;
int arr[200009];
int main() {
  int n, a, b, i, z = 1000000009, k;
  string s;
  cin >> n >> s;
  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') k = (arr[i + 1] - arr[i]) / 2;
    z = min(z, k);
  }
  if (z == 1000000009)
    cout << "-1" << endl;
  else
    cout << z << endl;
  return 0;
}
