#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int arr[n];
  int c, z = -1;
  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') {
      c = abs(arr[i + 1] - arr[i]) / 2;
      if (z == -1 || c < z) {
        z = c;
      }
    }
  }
  cout << z << endl;
  return 0;
}
