#include <bits/stdc++.h>
using namespace std;
template <typename type>
type input() {
  type var;
  cin >> var;
  return var;
}
template <typename type>
void input(type &var) {
  cin >> var;
  return;
}
template <typename type>
void output(type &var, const char *ch) {
  cout << var << ch;
}
int min(int a, int b) { return a > b ? b : a; }
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int a[3] = {0, 0, int(1e9 + 4)};
  cin >> a[0];
  for (int i = 1; i < S.length(); i++) {
    cin >> a[1];
    if ((S[i] != S[i - 1]) && (S[i - 1] == 'R')) {
      a[2] = min(a[2], (a[1] - a[0]) / 2);
    }
    a[0] = a[1];
  }
  if (a[2] == 1e9 + 4)
    cout << "-1";
  else
    cout << a[2];
  return 0;
}
