#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
int sum[maxn << 2], tag[maxn << 2], mi[maxn << 2], mx[maxn << 2];
inline void pushup(int x) {
  sum[x] = sum[x << 1] + sum[x << 1 | 1];
  mi[x] = min(mi[x << 1], mi[x << 1 | 1]);
  mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}
inline void pushdown(int x, int l, int r) {
  if (!tag[x]) return;
  int mid = l + r >> 1;
  sum[x << 1] += (mid - l + 1) * tag[x];
  sum[x << 1 | 1] += (r - mid) * tag[x];
  mi[x << 1] += tag[x];
  mi[x << 1 | 1] += tag[x];
  mx[x << 1] += tag[x];
  mx[x << 1 | 1] += tag[x];
  tag[x << 1] += tag[x];
  tag[x << 1 | 1] += tag[x];
  tag[x] = 0;
}
void update(int l, int r, int x, int ql, int qr, int val) {
  if (ql <= l && r <= qr) {
    tag[x] += val;
    sum[x] += val * (r - l + 1);
    mi[x] += val;
    mx[x] += val;
    return;
  }
  pushdown(x, l, r);
  int mid = l + r >> 1;
  if (ql <= mid) update(l, mid, x << 1, ql, qr, val);
  if (qr > mid) update(mid + 1, r, x << 1 | 1, ql, qr, val);
  pushup(x);
}
int Query(int l, int r, int x, int q) {
  if (l == r) return sum[x];
  pushdown(x, l, r);
  int mid = l + r >> 1, ret;
  if (q <= mid)
    ret = Query(l, mid, x << 1, q);
  else
    ret = Query(mid + 1, r, x << 1 | 1, q);
  pushup(x);
  return ret;
}
string s;
int num[maxn] = {};
int main() {
  int n, now = 1;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    switch (s[i]) {
      case 'R':
        now++;
        break;
      case 'L':
        if (now > 1) now--;
        break;
      case '(':
        if (num[now] != 1) {
          update(1, n, 1, now, n, 1 - num[now]);
          num[now] = 1;
        }
        break;
      case ')':
        if (num[now] != -1) {
          update(1, n, 1, now, n, -1 - num[now]);
          num[now] = -1;
        }
        break;
      default:
        update(1, n, 1, now, n, -num[now]);
        num[now] = 0;
    }
    if (Query(1, n, 1, n) == 0 && mi[1] >= 0)
      cout << mx[1] << ' ';
    else
      cout << -1 << ' ';
  }
  return 0;
}
