#include <bits/stdc++.h>
#pragma GCC optimize(2)
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
inline int read() {
  int num = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    num = (num << 3) + (num << 1) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -num : num;
}
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
using namespace std;
int n, pos = 1;
char s[N];
struct node {
  int sum, mi, mx;
} tree[N << 2];
void updata(int rt, int l, int r, int pos, int val) {
  if (l == r) {
    tree[rt].sum = tree[rt].mi = tree[rt].mx = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    updata(rt << 1, l, mid, pos, val);
  else
    updata(rt << 1 | 1, mid + 1, r, pos, val);
  tree[rt].sum = tree[rt << 1].sum + tree[rt << 1 | 1].sum;
  tree[rt].mx = (tree[rt << 1].mx < tree[rt << 1 | 1].mx + tree[rt << 1].sum
                     ? tree[rt << 1 | 1].mx + tree[rt << 1].sum
                     : tree[rt << 1].mx);
  tree[rt].mi = (tree[rt << 1].mi > tree[rt << 1 | 1].mi + tree[rt << 1].sum
                     ? tree[rt << 1 | 1].mi + tree[rt << 1].sum
                     : tree[rt << 1].mi);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  char ch;
  scanf("%d%c", &n, &ch);
  for (int i = 0; i < n; ++i) {
    scanf("%c", &ch);
    if (ch == 'L')
      pos = pos == 1 ? pos : pos - 1;
    else if (ch == 'R')
      ++pos;
    else if (ch == '(')
      updata(1, 1, n, pos, 1);
    else if (ch == ')')
      updata(1, 1, n, pos, -1);
    else
      updata(1, 1, n, pos, 0);
    if (tree[1].mi == 0 && tree[1].sum == 0)
      printf("%d ", tree[1].mx);
    else
      printf("%d ", -1);
  }
  return 0;
}
