#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, cnt = 0, flag, Min;
  char a[200001];
  int b[200001];
  int c[200001];
  while (~scanf("%d", &n)) {
    flag = 0;
    Min = 0x3f3f3f3f;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    scanf("%s", a);
    for (i = 0; i < n; i++) {
      scanf("%d", &b[i]);
    }
    for (i = 0; i < n; i++) {
      if (a[i] == 'L' && a[i - 1] == 'R') {
        flag = 1;
        Min = min(Min, abs(b[i] - b[i - 1]) / 2);
      }
    }
    if (flag == 0) {
      printf("-1\n");
      continue;
    } else
      printf("%d\n", Min);
  }
  return 0;
}
