#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int mods[10] = {1000000007, 999999937, 999999929, 999999893, 999999883,
                      999999797,  999999761, 999999757, 999999751, 999999739};
const int mod = 1000000007, mod2 = 998244353;
int rand_mods[2];
const long double eps = 1e-10;
const int siz = 1e6 + 5, siz2 = 3e5 + 5, lg = 20, block = 300, block2 = 1000,
          mxv = 1e5 + 1, sqrt_mod = 31630;
const int alpha_sz = 26;
int n;
char str[siz];
struct tnode {
  int sum, mx, mn;
};
tnode tree[siz * 4];
bool isb[siz];
void update(int node, int s, int e, int i, int v) {
  if (s == e) {
    tree[node] = {v, v, v};
    return;
  }
  int mid = (s + e) / 2;
  if (i <= mid) {
    update(node * 2, s, mid, i, v);
  } else {
    update(node * 2 + 1, mid + 1, e, i, v);
  }
  tree[node] = {
      tree[node * 2].sum + tree[node * 2 + 1].sum,
      max(tree[node * 2].mx, tree[node * 2].sum + tree[node * 2 + 1].mx),
      min(tree[node * 2].mn, tree[node * 2].sum + tree[node * 2 + 1].mn)};
}
int main() {
  scanf("%d%s", &n, str);
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'L') {
      if (cur) {
        cur--;
      }
    } else if (str[i] == 'R') {
      cur++;
    } else if (str[i] == '(') {
      update(1, 0, 1e6, cur, 1);
      isb[cur] = 1;
    } else if (str[i] == ')') {
      update(1, 0, 1e6, cur, -1);
      isb[cur] = 1;
    } else {
      if (isb[cur]) {
        update(1, 0, 1e6, cur, 0);
      }
      isb[cur] = 0;
    }
    if (tree[1].sum != 0 || tree[1].mn < 0) {
      printf("-1 ");
    } else {
      printf("%d ", tree[1].mx);
    }
  }
  printf("\n");
  return 0;
}
