#include <bits/stdc++.h>
using namespace std;
int n;
char s[200100];
int pos[200100];
int main() {
  scanf("%d", &n);
  int mn = -1;
  scanf("%s", s);
  for (int i = 0; i < n; i++) scanf("%d", &pos[i]);
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'R' && s[i] == 'L')
      if (mn == -1 || mn > (pos[i] - pos[i - 1]) / 2)
        mn = (pos[i] - pos[i - 1]) / 2;
  }
  printf("%d\n", mn);
  return 0;
}
