#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
inline int add(int a, int b) {
  if ((a += b) >= P) a -= P;
  return a;
}
inline int sub(int a, int b) {
  if ((a -= b) < 0) a += P;
  return a;
}
inline int mul(int a, int b) { return 1ll * a * b % P; }
inline int kpow(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) r = mul(r, a);
  }
  return r;
}
namespace SegTree {
const int N = 1010101, M = N << 2;
const int INF = 1e9 + 7;
int lzy[M], mx[M], mn[M];
void up(int id) {
  mx[id] = max(mx[id << 1], mx[id << 1 | 1]);
  mn[id] = min(mn[id << 1], mn[id << 1 | 1]);
}
void down(int id, int nl, int nr) {
  int mid = nl + nr >> 1;
  if (lzy[id]) {
    mx[id << 1] += lzy[id], mx[id << 1 | 1] += lzy[id];
    mn[id << 1] += lzy[id], mn[id << 1 | 1] += lzy[id];
    lzy[id << 1] += lzy[id], lzy[id << 1 | 1] += lzy[id];
    lzy[id] = 0;
  }
}
void upd(int id, int nl, int nr, int l, int r, int val) {
  if (r < nl || l > nr) return;
  if (l <= nl && r >= nr) {
    mn[id] += val, mx[id] += val;
    lzy[id] += val;
    return;
  }
  down(id, nl, nr);
  int mid = nl + nr >> 1;
  upd(id << 1, nl, mid, l, r, val);
  upd(id << 1 | 1, mid + 1, nr, l, r, val);
  up(id);
}
int qry(int id, int nl, int nr, int l, int r) {
  if (l > nr || r < nl) return -INF;
  if (l <= nl && r >= nr) return mx[id];
  down(id, nl, nr);
  int mid = nl + nr >> 1;
  return max(qry(id << 1, nl, mid, l, r), qry(id << 1 | 1, mid + 1, nr, l, r));
}
}  // namespace SegTree
const int N = 1010101, RMOST = 1000000;
int n;
char s[N];
int op[N];
int main() {
  scanf("%d\n", &n);
  gets(s);
  int p = 0;
  int ans = 0;
  using namespace SegTree;
  for (int i = (0); i < (n); i++) {
    if (s[i] == 'L') {
      p--;
      p = max(p, 0);
    } else if (s[i] == 'R') {
      p++;
    } else {
      if (s[i] == '(') {
        int up = 0;
        if (op[p] == 0) up = 1;
        if (op[p] == 1) up = 0;
        if (op[p] == -1) up = 2;
        upd(1, 0, RMOST, p, RMOST, up);
        int sum = qry(1, 0, RMOST, RMOST, RMOST), mi = mn[1];
        if (mi >= 0 && sum == 0)
          ans = mx[1];
        else
          ans = -1;
        op[p] = 1;
      } else if (s[i] == ')') {
        int up = 0;
        if (op[p] == 0) up = -1;
        if (op[p] == 1) up = -2;
        if (op[p] == -1) up = 0;
        upd(1, 0, RMOST, p, RMOST, up);
        int sum = qry(1, 0, RMOST, RMOST, RMOST), mi = mn[1];
        if (mi >= 0 && sum == 0)
          ans = mx[1];
        else
          ans = -1;
        op[p] = -1;
      } else {
        int up = -op[p];
        upd(1, 0, RMOST, p, RMOST, up);
        int sum = qry(1, 0, RMOST, RMOST, RMOST), mi = mn[1];
        if (mi >= 0 && sum == 0)
          ans = mx[1];
        else
          ans = -1;
        op[p] = 0;
      }
    }
    printf("%d ", ans);
  }
  return 0;
}
