#include <bits/stdc++.h>
using namespace std;
inline void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
int a[int(1e6 + 5)], u[4 * int(1e6 + 5)];
struct vertex {
  int mn, mx;
};
vertex t[4 * int(1e6 + 5)];
vertex updVertex(int v, int val) {
  u[v] += val;
  t[v].mn += val;
  t[v].mx += val;
  return t[v];
}
void push(int v) {
  if (u[v] && (v << 1 | 1) < 4 * int(1e6 + 5)) {
    updVertex(v << 1, u[v]);
    updVertex(v << 1 | 1, u[v]);
    u[v] = 0;
  }
}
vertex upd(int v, int tl, int tr, int ql, int qr, int val) {
  if (ql >= qr) return {int(1e9 + 5), -int(1e9 + 5)};
  if (tl == ql && tr == qr) return updVertex(v, val);
  push(v);
  int mid = tl + tr >> 1;
  upd(v << 1, tl, mid, ql, min(mid, qr), val);
  upd(v << 1 | 1, mid, tr, max(ql, mid), qr, val);
  t[v].mn = min(t[v << 1].mn, t[v << 1 | 1].mn);
  t[v].mx = max(t[v << 1].mx, t[v << 1 | 1].mx);
  return t[v];
}
void solve() {
  int n, cnt = 0;
  string s;
  cin >> n >> s;
  string str(n, ' ');
  int pos = 0;
  int ans = 0;
  for (auto c : s) {
    if (c == 'L') {
      if (pos) pos--;
      cout << ans << ' ';
      continue;
    }
    if (c == 'R') {
      pos++;
      cout << ans << ' ';
      continue;
    }
    int val = 0;
    if (str[pos] == '(')
      val--, cnt--;
    else if (str[pos] == ')')
      val++, cnt++;
    if (c == '(') {
      val++, cnt++;
    } else if (c == ')') {
      val--, cnt--;
    }
    if (val) upd(1, 0, int(1e6 + 5), pos, int(1e6 + 5), val);
    str[pos] = c;
    int mn = t[1].mn;
    int mx = t[1].mx;
    if (mn < 0 || cnt)
      ans = -1;
    else
      ans = mx;
    cout << ans << ' ';
  }
}
