#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
int main() {
  int n;
  cin >> n;
  string direc;
  cin >> direc;
  int pos[maxn];
  for (int i = 0; i < n; i++) {
    cin >> pos[i];
  }
  bool collision = false;
  int min_dis = INT_MAX;
  for (int i = 0; i < n - 1; i++) {
    if (direc[i] == 'R' && direc[i + 1] == 'L') {
      min_dis = min(min_dis, pos[i + 1] - pos[i]);
      collision = true;
    }
  }
  if (collision) {
    cout << min_dis / 2 << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
