#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 1 << 30;
int vis[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, flag = 0;
  cin >> n;
  string s;
  long long int ar[200005], cnt = 1000000002;
  cin >> s;
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      if (((ar[i + 1] - ar[i]) / 2) < cnt)
        cnt = ((ar[i + 1] - ar[i]) / 2), flag++;
    }
  }
  if (flag)
    cout << cnt;
  else
    cout << -1;
  return 0;
}
