#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int maxn = 1e6 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n;
int mx[maxn << 2], mi[maxn << 2], lazy[maxn << 2], f[maxn];
char ss[maxn];
void push_down(int now) {
  int &d = lazy[now];
  mx[now << 1] += d, mx[now << 1 | 1] += d;
  mi[now << 1] += d, mi[now << 1 | 1] += d;
  lazy[now << 1] += d, lazy[now << 1 | 1] += d;
  d = 0;
}
void update(int x, int y, int d, int l, int r, int now) {
  if (x <= l && r <= y) {
    mx[now] += d;
    mi[now] += d;
    lazy[now] += d;
    return;
  }
  if (lazy[now]) push_down(now);
  int m = (l + r) / 2;
  if (x <= m) update(x, y, d, l, m, now << 1);
  if (y > m) update(x, y, d, m + 1, r, now << 1 | 1);
  mx[now] = (mx[now << 1] > mx[now << 1 | 1] ? mx[now << 1] : mx[now << 1 | 1]);
  mi[now] = (mi[now << 1] < mi[now << 1 | 1] ? mi[now << 1] : mi[now << 1 | 1]);
}
int query(int x, int l, int r, int now) {
  if (l == r) return lazy[now];
  if (lazy[now]) push_down(now);
  int m = (l + r) / 2;
  if (x <= m)
    return query(x, l, m, now << 1);
  else
    return query(x, m + 1, r, now << 1 | 1);
}
int main() {
  n = read() + 1;
  scanf("%s", ss + 1);
  int x = 1;
  for (int i = 1; i <= n - 1; ++i) {
    if (ss[i] == 'R')
      x++;
    else if (ss[i] == 'L')
      x = max(1, x - 1);
    else if (ss[i] == '(') {
      if (f[x] == -1)
        update(x, n, 2, 1, n, 1);
      else if (f[x] == 0)
        update(x, n, 1, 1, n, 1);
      f[x] = 1;
    } else if (ss[i] == ')') {
      if (f[x] == 1)
        update(x, n, -2, 1, n, 1);
      else if (f[x] == 0)
        update(x, n, -1, 1, n, 1);
      f[x] = -1;
    } else {
      if (f[x] == 1)
        update(x, n, -1, 1, n, 1);
      else if (f[x] == -1)
        update(x, n, 1, 1, n, 1);
      f[x] = 0;
    }
    if (!query(n, 1, n, 1) && mi[1] >= 0)
      printf("%d ", mx[1]);
    else
      printf("-1 ");
  }
}
