#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8;
const long double pi = 3.141592653589793238;
const int MOD = 998244353;
const int N = 1e6 + 22;
int n;
pair<int, int> seg[4 * N];
int lazy[4 * N];
int a[N] = {0};
pair<int, int> fun(pair<int, int> a, pair<int, int> b) {
  a.first = min(a.first, b.first);
  a.second = max(a.second, b.second);
  return a;
}
void rangeUpdate(int ind, int low, int high, int l, int r, int val) {
  if (lazy[ind] != 0) {
    seg[ind].first += lazy[ind];
    seg[ind].second += lazy[ind];
    if (low != high) {
      lazy[2 * ind + 1] += lazy[ind];
      lazy[2 * ind + 2] += lazy[ind];
    }
    lazy[ind] = 0;
  }
  if (r < low || l > high || low > high) return;
  if (low >= l && high <= r) {
    seg[ind].first += val;
    seg[ind].second += val;
    if (low != high) {
      lazy[2 * ind + 1] += val;
      lazy[2 * ind + 2] += val;
    }
    return;
  }
  int mid = (low + high) / 2;
  rangeUpdate(2 * ind + 1, low, mid, l, r, val);
  rangeUpdate(2 * ind + 2, mid + 1, high, l, r, val);
  seg[ind] = fun(seg[2 * ind + 1], seg[2 * ind + 2]);
}
pair<int, int> querylazy(int ind, int low, int high, int l, int r) {
  if (lazy[ind] != 0) {
    seg[ind].first += lazy[ind];
    seg[ind].second += lazy[ind];
    if (low != high) {
      lazy[2 * ind + 1] += lazy[ind];
      lazy[2 * ind + 2] += lazy[ind];
    }
    lazy[ind] = 0;
  }
  if (r < low || l > high || low > high) return make_pair(inf, -inf);
  if (l <= low && high <= r) return seg[ind];
  int mid = (low + high) / 2;
  return fun(querylazy(2 * ind + 1, low, mid, l, r),
             querylazy(2 * ind + 2, mid + 1, high, l, r));
}
void solve() {
  cin >> n;
  string s;
  cin >> s;
  int cur = 1;
  memset(seg, 0, sizeof(seg));
  memset(lazy, 0, sizeof(lazy));
  int tot = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      cur++;
    else if (s[i] == 'L')
      cur--, cur = max(1, cur);
    else {
      int val = a[cur];
      tot -= val;
      rangeUpdate(0, 0, N - 1, cur, N - 1, -val);
      a[cur] = 0;
      if (s[i] == '(')
        a[cur] = 1;
      else if (s[i] == ')')
        a[cur] = -1;
      val = a[cur];
      tot += val;
      rangeUpdate(0, 0, N - 1, cur, N - 1, val);
    }
    pair<int, int> p = querylazy(0, 0, N - 1, 0, N - 1);
    if (tot == 0 && p.first >= 0)
      cout << p.second << " ";
    else
      cout << -1 << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
