#include <bits/stdc++.h>
using namespace std;
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int arr[200005];
int main() {
  init();
  int n;
  string s;
  cin >> n >> s;
  for (long long int(i) = (0); (i) < (n); ++(i)) {
    cin >> arr[i];
  }
  int mins = INT_MAX;
  for (long long int(i) = (1); (i) < (n); ++(i)) {
    if (s[i] == 'L' && s[i - 1] == 'R') {
      mins = min(mins, (arr[i] - arr[i - 1]) / 2);
    }
  }
  if (mins == INT_MAX)
    cout << -1 << '\n';
  else
    cout << mins << '\n';
  return 0;
}
