#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 7, Inf = 1e9 + 7;
int n, m, k = Inf, x, l, r, f, a[inf], b[inf], c[inf], d[inf];
map<int, int> p[inf];
vector<int> v;
string s;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i)
    if (s[i] == 'L' && s[i - 1] == 'R') k = min(k, (a[i] - a[i - 1]) / 2);
  if (k == Inf)
    cout << -1;
  else
    cout << k;
}
