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