#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000001;
char s[200005];
int a[200005], b[200005];
int main() {
  int i, n, ans = inf + 1;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = (s[i] == 'L' ? 0 : 1);
  }
  for (i = 1; i < n; i++)
    if (b[i] && !b[i + 1]) ans = min(ans, (a[i + 1] - a[i]) / 2);
  if (ans > inf) ans = -1;
  printf("%d\n", ans);
  return 0;
}
