#include <bits/stdc++.h>
using namespace std;
struct node {
  int sum, maxn, minn;
} tr[4000010];
char c[1000010];
void change(int k, int l, int r, int x, int P) {
  if (l == r) {
    tr[k].sum = tr[k].minn = tr[k].maxn = x;
    return;
  }
  int mid = (l + r) >> 1;
  if (P <= mid)
    change(k * 2, l, mid, x, P);
  else
    change(k * 2 + 1, mid + 1, r, x, P);
  tr[k].sum = tr[k * 2].sum + tr[k * 2 + 1].sum;
  tr[k].maxn = max(tr[k * 2].maxn, tr[k * 2].sum + tr[k * 2 + 1].maxn);
  tr[k].minn = min(tr[k * 2].minn, tr[k * 2].sum + tr[k * 2 + 1].minn);
  return;
}
int main() {
  int n, P = 1;
  scanf("%d", &n);
  scanf("%s", c);
  for (int i = 0; i < n; i++) {
    if (c[i] == 'L')
      (P == 1) ? P = P : P = P - 1;
    else if (c[i] == 'R')
      P++;
    else if (c[i] == '(')
      change(1, 1, n, 1, P);
    else if (c[i] == ')')
      change(1, 1, n, -1, P);
    else
      change(1, 1, n, 0, P);
    if (tr[1].sum != 0 || tr[1].minn < 0)
      printf("-1 ");
    else
      printf("%d ", tr[1].maxn);
  }
  return 0;
}
