#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int maxn = 200005;
char d[maxn];
int x[maxn];
int main() {
  int n, ans = inf;
  scanf("%d%s", &n, d);
  for (int i = 0; i < n; ++i) scanf("%d", x + i);
  for (int i = 1; i < n; ++i) {
    if (d[i - 1] == 'R' && d[i] == 'L') ans = min(ans, (x[i] - x[i - 1]) / 2);
  }
  if (ans == inf) ans = -1;
  printf("%d", ans);
}
