#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const int MAXN = 1e6 + 10;
const int MAXM = 3e3 + 10;
priority_queue<int> pq;
vector<pair<int, int> > tree;
vector<int> lazy;
char S[MAXN];
int A[MAXN];
void update_lazy(int node, int st, int en) {
  if (!lazy[node]) return;
  tree[node].first += lazy[node];
  tree[node].second += lazy[node];
  if (st != en) {
    lazy[node << 1] += lazy[node];
    lazy[(node << 1) | 1] += lazy[node];
  }
  lazy[node] = 0;
}
void update_range(int node, int st, int en, int L, int R, int val) {
  update_lazy(node, st, en);
  if (L > en | R < st) return;
  if (L <= st && en <= R) {
    tree[node].first += val;
    tree[node].second += val;
    if (st != en) {
      lazy[node << 1] += val;
      lazy[(node << 1) | 1] += val;
    }
    return;
  }
  update_range(node << 1, st, (st + en) >> 1, L, R, val);
  update_range((node << 1) | 1, ((st + en) >> 1) + 1, en, L, R, val);
  tree[node].first = max(tree[node << 1].first, tree[(node << 1) | 1].first);
  tree[node].second = min(tree[node << 1].second, tree[(node << 1) | 1].second);
  return;
}
int main() {
  int n, m, k, a, b, x, y;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  cin >> S;
  int h = (int)ceil(log2(n));
  int tree_size = (1 << (h + 1));
  tree = vector<pair<int, int> >(tree_size);
  lazy = vector<int>(tree_size);
  int idx = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (S[i] == 'R') {
      if (idx < n - 1) idx++;
    } else if (S[i] == 'L') {
      if (idx) idx--;
    } else {
      update_range(1, 0, n - 1, idx, n - 1, -A[idx]);
      cnt -= A[idx];
      if (S[i] == '(')
        A[idx] = 1;
      else if (S[i] == ')')
        A[idx] = -1;
      else
        A[idx] = 0;
      cnt += A[idx];
      update_range(1, 0, n - 1, idx, n - 1, A[idx]);
    }
    if (cnt != 0)
      cout << "-1 ";
    else if (tree[1].second < 0)
      cout << "-1 ";
    else
      cout << tree[1].first << " ";
  }
  return 0;
}
