#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  string s;
  cin >> s;
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int flag = 0, mn = 1000000000, mid, x, y, d;
  for (i = 0; i < n; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      flag = 1;
      x = a[i];
      y = a[i + 1];
      mid = (x + y) / 2;
      d = mid - x;
      if (d < mn) mn = d;
    }
  }
  if (flag) {
    cout << mn;
  } else
    cout << "-1";
  return 0;
}
