#include <bits/stdc++.h>
const long long inf = 1e10;
const int maxn = 200000 + 10;
struct NN {
  int d;
  int x;
} node[maxn];
int main() {
  char a;
  int n;
  while (std::cin >> n) {
    for (int i = 0; i < n; i++) {
      std::cin >> a;
      if (a == 'R')
        node[i].d = 1;
      else
        node[i].d = 0;
    }
    for (int i = 0; i < n; i++) {
      std::cin >> node[i].x;
    }
    long long minn = inf;
    for (int i = 0; i < n - 1; i++) {
      if (node[i].d == 1 && node[i + 1].d == 0) {
        if (node[i + 1].x - node[i].x < minn) minn = node[i + 1].x - node[i].x;
      }
    }
    if (minn == inf)
      std::cout << -1 << std::endl;
    else
      std::cout << minn / 2 << std::endl;
  }
}
