#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i;
  int minn = 1000000001;
  int flag = 0;
  int a[200000];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      minn = min(minn, (a[i + 1] - a[i]) / 2);
      flag = 1;
    }
  }
  if (flag == 1)
    cout << minn;
  else
    cout << "-1";
  return 0;
}
