#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
char s[N];
int a[N];
int main() {
  int n, i, ans = 1e9 + 1;
  cin >> n;
  scanf("%s", s + 1);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i < n; i++)
    if (s[i] == 'R' && s[i + 1] == 'L') ans = min(ans, a[i + 1] - a[i] >> 1);
  if (ans == 1e9 + 1)
    cout << -1;
  else
    cout << ans;
  return 0;
}
