#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[200010], m = INT_MAX;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int j = -1;
  for (long long int i = 0; i < s.length(); i++) {
    if (s[i] == 'R')
      j = i;
    else {
      if (j != -1) {
        long long int temp = abs(a[i] - a[j]) / 2;
        if (temp < m) m = temp;
      }
    }
  }
  if (m == INT_MAX)
    cout << -1;
  else
    cout << m;
}
