#include <bits/stdc++.h>
const int N = 200500;
using namespace std;
struct arr {
  long long as;
} a[N];
int main() {
  long long b[N];
  char c[N];
  int n;
  cin >> n;
  cin >> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i].as;
  }
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] == 'R' && c[i + 1] == 'L') {
      b[j++] = (a[i + 1].as - a[i].as) / 2;
      i++;
    }
  }
  sort(b, b + j);
  if (j)
    cout << b[0] << endl;
  else
    cout << "-1" << endl;
  return 0;
}
