#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  bool f = 0;
  cin >> n;
  string s;
  int sp[n];
  cin >> s;
  int lol = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> sp[i];
  }
  for (int i = 0; i < n; i += 1) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      lol = min(lol, (sp[i + 1] - sp[i]));
    }
  }
  if (lol == INT_MAX)
    cout << -1;
  else
    cout << lol / 2;
}
