#include <bits/stdc++.h>
using namespace std;
int d[1234678], a[1234678], ans;
int main() {
  int n, cnt = 0;
  char c;
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%c", &c);
    d[i] = (c == 'R');
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  ans = 1047483647;
  for (int i = 2; i <= n; i++)
    if (d[i - 1] == 1 && d[i] == 0) ans = min(ans, (a[i] - a[i - 1]) / 2);
  if (ans == 1047483647)
    puts("-1");
  else
    printf("%d\n", ans);
}
