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