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