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