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