#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 9;
const int N = 1e6;
int cur = 1, tot, q, val[MAXN];
string s;
struct Node {
  Node *lc, *rc;
  int minv, maxv, add;
  inline void upd() {
    if (lc && rc) {
      minv = min(lc->minv, rc->minv);
      maxv = max(lc->maxv, rc->maxv);
    }
    minv += add;
    maxv += add;
    if (!lc && !rc) add = 0;
  }
  inline void down() {
    lc->add += add;
    rc->add += add;
    add = 0;
  }
} pool[MAXN * 2], *pt = pool, *root;
void build(Node* t, int l, int r) {
  if (l == r) return;
  int m = (l + r) / 2;
  build(t->lc = pt++, l, m);
  build(t->rc = pt++, m + 1, r);
}
void modify(Node* t, int l, int r, int ql, int qr, int add) {
  if (ql <= l && r <= qr) {
    t->add += add;
  } else {
    t->down();
    int m = (l + r) / 2;
    ql <= m ? modify(t->lc, l, m, ql, qr, add) : t->lc->upd();
    m < qr ? modify(t->rc, m + 1, r, ql, qr, add) : t->rc->upd();
  }
  t->upd();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  build(root = pt++, 1, N);
  cin >> q >> s;
  for (auto e : s) {
    if (e == 'L')
      cur = max(cur - 1, 1);
    else if (e == 'R')
      cur++;
    else {
      modify(root, 1, N, cur, N, -val[cur]);
      tot -= val[cur];
      if (e == '(') {
        tot++;
        val[cur] = 1;
        modify(root, 1, N, cur, N, 1);
      } else if (e == ')') {
        tot--;
        val[cur] = -1;
        modify(root, 1, N, cur, N, -1);
      } else {
        val[cur] = 0;
      }
    }
    if (root->minv == 0 && tot == 0) {
      cout << root->maxv << ' ';
    } else {
      cout << "-1 ";
    }
  }
  return 0;
}
