#include <bits/stdc++.h>
int main() {
  int n, a[200000], i, min = 1000000000, c = 0;
  char s[200001];
  scanf("%d%s", &n, s);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n - 1; i++)
    if (s[i] == 'R' && s[i + 1] == 'L') {
      c++;
      if ((a[i + 1] - a[i]) / 2 < min) min = (a[i + 1] - a[i]) / 2;
    }
  if (c)
    printf("%d\n", min);
  else
    printf("-1\n");
  return 0;
}
