#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int main() {
  int n, ans = 1e9;
  string s;
  cin >> n >> s;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L')
      ans = min(ans, ((arr[i + 1] - arr[i]) / 2));
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
  return 0;
}
