#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 1.1e6;
const int INF = (int)1e9;
const int MOD = (int)(1e9 + 7);
const int MAX = (int)(1.5e7) + 10;
int t[4 * MAXN];
int tmin[4 * MAXN];
int lazy[4 * MAXN];
void push(int v) {
  t[v * 2] += lazy[v];
  tmin[v * 2] += lazy[v];
  lazy[v * 2] += lazy[v];
  t[v * 2 + 1] += lazy[v];
  tmin[v * 2 + 1] += lazy[v];
  lazy[v * 2 + 1] += lazy[v];
  lazy[v] = 0;
}
void update(int v, int tl, int tr, int l, int r, int addend) {
  if (l > r) return;
  if (l == tl && tr == r) {
    t[v] += addend;
    tmin[v] += addend;
    lazy[v] += addend;
  } else {
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(r, tm), addend);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, addend);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
    tmin[v] = min(tmin[v * 2], tmin[v * 2 + 1]);
  }
}
int query(int v, int tl, int tr, int l, int r) {
  if (l > r) return -INF;
  if (l <= tl && tr <= r) return t[v];
  push(v);
  int tm = (tl + tr) / 2;
  return max(query(v * 2, tl, tm, l, min(r, tm)),
             query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int querymin(int v, int tl, int tr, int l, int r) {
  if (l > r) return INF;
  if (l <= tl && tr <= r) return tmin[v];
  push(v);
  int tm = (tl + tr) / 2;
  return min(query(v * 2, tl, tm, l, min(r, tm)),
             query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
bool open[2 * MAXN];
bool close[2 * MAXN];
bool weijgwueg[2 * MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  const int HIGH = MAXN - 1;
  int cur = 0;
  fill(weijgwueg, weijgwueg + 2 * MAXN, true);
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      if (close[cur]) {
        update(1, 0, HIGH, cur, HIGH, -2);
      } else if (weijgwueg[cur]) {
        update(1, 0, HIGH, cur, HIGH, -1);
      }
      close[cur] = false;
      open[cur] = true;
      weijgwueg[cur] = false;
    } else if (s[i] == ')') {
      if (open[cur]) {
        update(1, 0, HIGH, cur, HIGH, +2);
      } else if (weijgwueg[cur]) {
        update(1, 0, HIGH, cur, HIGH, +1);
      }
      close[cur] = true;
      open[cur] = false;
      weijgwueg[cur] = false;
    } else if (s[i] == 'L') {
      cur--;
      if (cur < 0) cur = 0;
    } else if (s[i] == 'R') {
      cur++;
    } else {
      if (!weijgwueg[cur]) {
        if (open[cur]) update(1, 0, HIGH, cur, HIGH, +1);
        if (close[cur]) update(1, 0, HIGH, cur, HIGH, -1);
      }
      open[cur] = close[cur] = false;
      weijgwueg[cur] = true;
    }
    int all = query(1, 0, HIGH, 0, HIGH);
    int back = query(1, 0, HIGH, HIGH, HIGH);
    if (all == 0 && back == 0) {
      cout << -1 * querymin(1, 0, HIGH, 0, HIGH) << ' ';
    } else {
      cout << "-1 ";
    }
  }
  cout << '\n';
  return 0;
}
