#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n;
char s[N];
char a[N];
struct Tree {
  int l, r;
  int maxn;
  int minn;
  int add;
} tree[4 * N + 5];
int tot;
void PushUp(int i) {
  tree[i].minn = min(tree[i * 2].minn, tree[i * 2 + 1].minn);
  tree[i].maxn = max(tree[i * 2].maxn, tree[i * 2 + 1].maxn);
}
void PushDown(int i) {
  if (tree[i].add != 0) {
    int x = tree[i].add;
    tree[i].add = 0;
    tree[i * 2].add += x;
    tree[i * 2 + 1].add += x;
    tree[i * 2].maxn += x;
    tree[i * 2 + 1].maxn += x;
    tree[i * 2].minn += x;
    tree[i * 2 + 1].minn += x;
  }
}
void Add(int i, int l, int r, int x) {
  if (tree[i].l == l && tree[i].r == r) {
    tree[i].add += x;
    tree[i].maxn += x;
    tree[i].minn += x;
    return;
  }
  PushDown(i);
  int mid = (tree[i].l + tree[i].r) / 2;
  if (r <= mid) Add(i * 2, l, r, x);
  if (l >= mid + 1) Add(i * 2 + 1, l, r, x);
  if (l <= mid && r >= mid + 1) {
    Add(i * 2, l, mid, x);
    Add(i * 2 + 1, mid + 1, r, x);
  }
  PushUp(i);
}
void Build(int i, int l, int r) {
  tree[i].l = l;
  tree[i].r = r;
  if (l == r) return;
  int mid = (l + r) / 2;
  Build(i * 2, l, mid);
  Build(i * 2 + 1, mid + 1, r);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  int p = 1;
  Build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'R') {
      p++;
      if (tot != 0 || tree[1].minn < 0)
        printf("-1 ");
      else
        printf("%d ", tree[1].maxn);
      continue;
    }
    if (s[i] == 'L') {
      p--;
      if (p <= 0) p = 1;
      if (tot != 0 || tree[1].minn < 0)
        printf("-1 ");
      else
        printf("%d ", tree[1].maxn);
      continue;
    }
    if (a[p] == '(') {
      tot--;
      Add(1, p, n, -1);
    }
    if (a[p] == ')') {
      tot++;
      Add(1, p, n, 1);
    }
    if (s[i] == '(') {
      tot++;
      Add(1, p, n, 1);
    }
    if (s[i] == ')') {
      tot--;
      Add(1, p, n, -1);
    }
    a[p] = s[i];
    if (tot != 0 || tree[1].minn < 0)
      printf("-1 ");
    else
      printf("%d ", tree[1].maxn);
  }
}
