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