#include <bits/stdc++.h>
using namespace std;
int n;
long long x[2000005];
int type[2000005];
char str[2000005];
int main() {
  scanf("%d", &n);
  scanf("%s", str);
  for (int i = 0; i < n; i++) scanf("%I64d", &x[i]);
  for (int i = 0; i < n; i++)
    if (str[i] == 'L')
      type[i] = -1;
    else
      type[i] = 1;
  long long ans = -1;
  for (int i = 0; i < n - 1; i++) {
    if (type[i] == 1 && type[i + 1] == -1) {
      if (ans == -1)
        ans = (x[i + 1] - x[i]) / 2;
      else
        ans = min(ans, (x[i + 1] - x[i]) / 2);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
