#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  s = '*' + s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int mins = 1e9;
  for (int i = 1; i < n; i++)
    if (s[i] == 'R')
      if (s[i + 1] == 'L') {
        mins = min(mins, (a[i + 1] - a[i]) / 2);
      }
  if (mins != 1e9) {
    cout << mins;
  } else {
    cout << -1;
  }
  return 0;
}
