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