#include <bits/stdc++.h>
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
using namespace std;
long long ModExp(long long x, long long y, long long m) {
  long long res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    y = y >> 1;
    x = (x * x) % m;
  }
  return res;
}
struct segnode {
  long long mn;
  long long mx;
  long long lazy;
};
segnode tree[4000006];
long long arr[1000006];
long long pos = 1;
long long op = 0;
long long cl = 0;
segnode merge(segnode a, segnode b) {
  segnode res;
  res.mn = min(a.mn, b.mn);
  res.mx = max(a.mx, b.mx);
  res.lazy = 0;
  return res;
}
void build(long long n, long long s, long long e) {
  if (s == e) {
    tree[n].mn = arr[s];
    tree[n].mx = arr[s];
    tree[n].lazy = 0;
    return;
  }
  long long m = (s + e) / 2;
  build(n * 2, s, m);
  build(n * 2 + 1, m + 1, e);
  tree[n] = merge(tree[n * 2], tree[n * 2 + 1]);
}
void upd(long long n, long long s, long long e, long long l, long long r,
         long long v) {
  if (tree[n].lazy != 0) {
    tree[n].mn += tree[n].lazy;
    tree[n].mx += tree[n].lazy;
    if (s != e) {
      tree[n * 2].lazy += tree[n].lazy;
      tree[n * 2 + 1].lazy += tree[n].lazy;
    }
    tree[n].lazy = 0;
  }
  if (l > e || s > r || s > e || l > r) {
    return;
  }
  if (l <= s && e <= r) {
    tree[n].mn += v;
    tree[n].mx += v;
    if (s != e) {
      tree[n * 2].lazy += v;
      tree[n * 2 + 1].lazy += v;
    }
    return;
  }
  long long m = (s + e) / 2;
  upd(n * 2, s, m, l, r, v);
  upd(n * 2 + 1, m + 1, e, l, r, v);
  tree[n] = merge(tree[n * 2], tree[n * 2 + 1]);
}
void ch() {
  if (op == cl && tree[1].mn >= 0) {
    cout << tree[1].mx << " ";
  } else {
    cout << "-1 ";
  }
}
void solve() {
  string s = "";
  for (long long i = 0; i < 1000004; i++) {
    arr[i] = 0;
    s += " ";
  }
  build(1, 1, 1000000);
  long long n;
  cin >> n;
  string opr;
  cin >> opr;
  for (long long o = 0; o < opr.length(); o++) {
    char t = opr[o];
    if (t == 'L') {
      pos = max(pos - 1, 1LL);
      ch();
    } else if (t == 'R') {
      pos++;
      ch();
    } else if (t == '(') {
      if (s[pos] == '(') {
        ch();
      } else if (s[pos] == ')') {
        cl--;
        op++;
        upd(1, 1, 1000000, pos, 1000000, 2);
        ch();
      } else {
        op++;
        upd(1, 1, 1000000, pos, 1000000, 1);
        ch();
      }
      s[pos] = '(';
    } else if (t == ')') {
      if (s[pos] == '(') {
        op--;
        cl++;
        upd(1, 1, 1000000, pos, 1000000, -2);
        ch();
      } else if (s[pos] == ')') {
        ch();
      } else {
        cl++;
        upd(1, 1, 1000000, pos, 1000000, -1);
        ch();
      }
      s[pos] = ')';
    } else {
      if (s[pos] == '(') {
        op--;
        upd(1, 1, 1000000, pos, 1000000, -1);
      } else if (s[pos] == ')') {
        cl--;
        upd(1, 1, 1000000, pos, 1000000, 1);
      }
      ch();
      s[pos] = t;
    }
  }
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
