#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5, oo = 2e9;
char s[maxn];
int p[maxn], sh[maxn];
int ans = oo, n, i;
bool cmp(int a, int b) { return p[a] < p[b]; }
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    sh[i] = i;
  }
  sort(sh + 1, sh + n + 1, cmp);
  for (i = 2; i <= n; i++)
    if (s[sh[i - 1]] == 'R' && s[sh[i]] == 'L')
      ans = min(ans, (p[sh[i]] - p[sh[i - 1]]) / 2);
  if (ans == oo) ans = -1;
  printf("%d", ans);
  return 0;
}
