#include <bits/stdc++.h>
template <typename element_type>
std::vector<element_type> read_vector(int size);
using namespace std;
int main() {
  int particles;
  string direction;
  while (cin >> particles >> direction) {
    vector<int> start = read_vector<int>(particles);
    int best = -1;
    for (int i = 1; i < particles; i++)
      if (direction[i - 1] == 'R' && direction[i] == 'L')
        if (best == -1 || (start[i] - start[i - 1]) / 2 < best)
          best = (start[i] - start[i - 1]) / 2;
    cout << best << '\n';
  }
}
template <typename element_type>
std::vector<element_type> read_vector(int size) {
  std::vector<element_type> ret(size);
  for (int i = 0; i < size; i++) std::cin >> ret[i];
  return ret;
}
