#include <bits/stdc++.h>
using namespace std;
int main() {
  int min1 = 999999999;
  int a[200000];
  int n;
  cin >> n;
  string str;
  cin >> str;
  for (int i = 0; i < n; i++) cin >> a[i];
  bool b = 0;
  for (int i = 0; i < str.size() - 1; i++) {
    if (str[i] == 'R' && str[i + 1] == 'L') {
      b = 1;
      break;
    }
  }
  if (b == 0) {
    cout << -1;
    return 0;
  } else {
    for (int i = 0; i < n; i++)
      if (str[i] == 'R' && str[i + 1] == 'L')
        min1 = min(min1, (a[i + 1] - a[i]) / 2);
  }
  cout << min1;
  return 0;
}
