#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL), cout.precision(15);
  int N;
  cin >> N;
  string s;
  cin >> s;
  int res = 1e9 + 100;
  bool f = false;
  int prev = -1, cur = -1;
  for (int i = 0; i < N; i++) {
    if (i == 0)
      cin >> prev;
    else {
      cin >> cur;
      if (s[i - 1] == 'R' && s[i] == 'L')
        res = min(res, (cur - prev) / 2), f = true;
      prev = cur;
    }
  }
  cout << (f ? res : -1) << "\n";
  return 0;
}
