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