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