#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, lstans = -1, ans = -1;
char s[N];
int mx[N << 2], v[N << 2], mn[N << 2];
void pushup(int x, int l, int r) {
  v[x] = v[x << 1] + v[x << 1 | 1];
  mx[x] = max(mx[x << 1 | 1] + v[x << 1], mx[x << 1]);
  mn[x] = min(mn[x << 1 | 1] + v[x << 1], mn[x << 1]);
}
void modify(int pos, int val, int x, int l, int r) {
  if (l == r) {
    v[x] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    modify(pos, val, x << 1, l, mid);
  else
    modify(pos, val, x << 1 | 1, mid + 1, r);
  pushup(x, l, r);
}
int main() {
  cin >> n;
  scanf("%s", s + 1);
  int pos = 1;
  for (int i = 1; i <= n; i++) {
    ans = -1;
    if (s[i] == 'L')
      pos -= (pos == 1 ? 0 : 1);
    else if (s[i] == 'R')
      pos++;
    else if (s[i] == '(')
      modify(pos, 1, 1, 1, n);
    else if (s[i] == ')')
      modify(pos, -1, 1, 1, n);
    else
      modify(pos, 0, 1, 1, n);
    if (mn[1] != 0 || v[1] != 0)
      printf("-1 ");
    else
      printf("%d ", mx[1]);
  }
  puts("");
  return 0;
}
