#include <bits/stdc++.h>
using namespace std;
string q;
int bin[1000010];
struct node {
  int plus = 0, maxt = 0, mint = 0;
  int l = 0, r = 0;
} e[1000010 * 4];
class segtree {
 public:
  inline int ls(int x) { return x << 1; }
  inline int rs(int x) { return (x << 1) + 1; }
  void update(int x) {
    e[x].maxt = max(e[ls(x)].maxt, e[rs(x)].maxt);
    e[x].mint = min(e[ls(x)].mint, e[rs(x)].mint);
  }
  void push(int x) {
    if (e[x].plus == 0) return;
    e[ls(x)].maxt += e[x].plus;
    e[ls(x)].mint += e[x].plus;
    e[rs(x)].maxt += e[x].plus;
    e[rs(x)].mint += e[x].plus;
    e[ls(x)].plus += e[x].plus;
    e[rs(x)].plus += e[x].plus;
    e[x].plus = 0;
  }
  void build(int l, int r, int x) {
    e[x].l = l;
    e[x].r = r;
    if (l >= r) return;
    build(l, (l + r) >> 1, ls(x));
    build(((l + r) >> 1) + 1, r, rs(x));
  }
  void plus(int l, int r, int v, int x) {
    if (e[x].l >= l && e[x].r <= r) {
      e[x].maxt += v;
      e[x].mint += v;
      e[x].plus += v;
      return;
    }
    push(x);
    int mid = (e[x].l + e[x].r) >> 1;
    if (l <= mid) plus(l, r, v, ls(x));
    if (r > mid) plus(l, r, v, rs(x));
    update(x);
  }
} sgt;
int sum = 0;
int gett() {
  if (sum != 0) return -1;
  if (e[1].mint < 0) return -1;
  return e[1].maxt;
}
int main() {
  int N;
  cin >> N;
  cin >> q;
  int tot = 1;
  sgt.build(1, N, 1);
  for (int i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    if (q[i] == 'L') {
      if (tot > 1) --tot;
    } else if (q[i] == 'R') {
      ++tot;
    } else if (q[i] == '(') {
      int u = 1 - bin[tot];
      sum += u;
      bin[tot] = 1;
      if (u) sgt.plus(tot, N, u, 1);
    } else if (q[i] == ')') {
      int u = -1 - bin[tot];
      sum += u;
      bin[tot] = -1;
      if (u) sgt.plus(tot, N, u, 1);
    } else {
      int u = -bin[tot];
      sum += u;
      bin[tot] = 0;
      if (u) sgt.plus(tot, N, u, 1);
    }
    printf("%d", gett());
  }
  return 0;
}
