#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
  return sum * ff;
}
const int N = 1e6 + 5;
int n, m, ans;
string ch, tmp;
struct seg {
  int mi[N * 4], mx[N * 4], laz[N * 4];
  inline void pd(int rt, int l, int r) {
    if (laz[rt]) {
      laz[rt << 1] += laz[rt];
      laz[rt << 1 | 1] += laz[rt];
      mx[rt << 1] += laz[rt];
      mx[rt << 1 | 1] += laz[rt];
      mi[rt << 1] += laz[rt];
      mi[rt << 1 | 1] += laz[rt];
      laz[rt] = 0;
    }
  }
  inline void update(int rt, int l, int r, int ll, int rr, int v) {
    if (ll <= l && r <= rr) {
      mi[rt] += v;
      mx[rt] += v;
      laz[rt] += v;
      return;
    }
    pd(rt, l, r);
    int mid = l + r >> 1;
    if (ll <= mid) update(rt << 1, l, mid, ll, rr, v);
    if (rr > mid) update(rt << 1 | 1, mid + 1, r, ll, rr, v);
    mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]);
    mi[rt] = min(mi[rt << 1], mi[rt << 1 | 1]);
  }
};
seg T;
int main() {
  n = read();
  string ch, tmp(n + 1, ' ');
  cin >> ch;
  int pos = 1, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (ch[i] == 'R')
      pos++;
    else if (ch[i] == 'L')
      pos = max(pos - 1, 1);
    else {
      if (tmp[pos] == '(')
        T.update(1, 1, n, pos, n, -1), cnt--;
      else if (tmp[pos] == ')')
        T.update(1, 1, n, pos, n, 1), cnt++;
      tmp[pos] = ch[i];
      if (tmp[pos] == '(')
        T.update(1, 1, n, pos, n, 1), cnt++;
      else if (tmp[pos] == ')')
        T.update(1, 1, n, pos, n, -1), cnt--;
    }
    if (cnt != 0 || T.mi[1] < 0)
      printf("-1 ");
    else
      printf("%d ", T.mx[1]);
  }
  return 0;
}
