#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d;
  string s;
  cin >> n >> s;
  vector<long long int> v;
  long long int a[n];
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  for (long long int i = 0; i < n - 1; ++i) {
    d = a[i + 1] - a[i];
    if (s[i] == 'R' && s[i + 1] == 'L')
      v.push_back(d / 2);
    else if ((s[i] == 'R' && s[i + 1] == 'R') ||
             (s[i] == 'L' && s[i + 1] == 'L') ||
             (s[i] == 'L' && s[i + 1] == 'R'))
      ;
  }
  sort(v.begin(), v.end());
  if (v.size() == 0)
    cout << -1;
  else
    cout << v[0] << endl;
  return 0;
}
