#include <bits/stdc++.h>
using namespace std;
struct seg {
  long long sum, min, max;
  seg(long long val = 0) : sum(val), min(val), max(val) {}
  seg(const seg &x, const seg &y) {
    sum = x.sum + y.sum;
    min = ::min(x.min, x.sum + y.min);
    max = ::max(x.max, x.sum + y.max);
  }
};
template <typename T>
struct segtree {
  int n;
  vector<T> t;
  segtree(int n) : n(n), t(n * 2) {}
  void update(int i, const T &val) {
    for (t[i += n] = val; i /= 2;) t[i] = T(t[i * 2], t[i * 2 + 1]);
  }
  T query(int l, int r, const T &def = T()) {
    T a = def, b = def;
    for (int i = l + n, j = r + n; i < j; i /= 2, j /= 2) {
      if (i % 2) a = T(a, t[i++]);
      if (j % 2) b = T(b, t[--j]);
    }
    return T(a, b);
  }
};
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  segtree<seg> t(n);
  int ans = 0;
  for (int i = 0, pos = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      if (pos > 0) pos--;
    } else if (s[i] == 'R') {
      pos++;
    } else if (s[i] == '(') {
      t.update(pos, seg(1));
    } else if (s[i] == ')') {
      t.update(pos, seg(-1));
    } else
      t.update(pos, seg(0));
    seg r = t.query(0, n - 1);
    if (r.sum == 0 && r.min == 0)
      cout << r.max << ' ';
    else
      cout << -1 << ' ';
  }
  cout << endl;
  return 0;
}
