#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
  return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
  return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
             << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
  return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
             << ", " << get<3>(a) << "}";
}
template <class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
  out << "[";
  for (int i = 0; i < int(a.size()); ++i)
    out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
  return out;
}
void smain();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(12) << fixed;
  smain();
  return 0;
}
const int N = 1e6 + 100, M = 1e6 + 10;
pair<int, int> t[4 * N];
int pushing[4 * N];
void push(int v) {
  pushing[v << 1] += pushing[v];
  pushing[v << 1 | 1] += pushing[v];
  t[v].first += pushing[v];
  t[v].second += pushing[v];
  pushing[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int kek) {
  if (tl == l && tr == r) {
    pushing[v] += kek;
  }
  if (tl < tr) {
    push(v);
  } else if (tl == tr) {
    t[v].first += pushing[v];
    t[v].second += pushing[v];
    pushing[v] = 0;
  }
  if (l > r) return;
  if (!(tl == l && tr == r)) {
    int tm = tl + tr >> 1;
    upd(v << 1, tl, tm, l, min(tm, r), kek);
    upd(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r, kek);
    t[v].first = min(t[v << 1].first, t[v << 1 | 1].first);
    t[v].second = max(t[v << 1].second, t[v << 1 | 1].second);
  }
}
void smain() {
  int n;
  string s;
  cin >> n >> s;
  string text;
  for (int i = 0; i < M; i++) {
    text += ' ';
  }
  vector<int> cnt(2);
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      cur--;
      if (cur < 0) cur = 0;
    } else if (s[i] == 'R') {
      cur++;
    } else {
      if (text[cur] == ')') {
        upd(1, 0, M - 1, cur, M - 1, 1);
        cnt[1]--;
      } else if (text[cur] == '(') {
        upd(1, 0, M - 1, cur, M - 1, -1);
        cnt[0]--;
      }
      text[cur] = s[i];
      if (text[cur] == ')') {
        upd(1, 0, M - 1, cur, M - 1, -1);
        cnt[1]++;
      } else if (text[cur] == '(') {
        upd(1, 0, M - 1, cur, M - 1, 1);
        cnt[0]++;
      }
    }
    if (t[1].first == 0 && cnt[0] == cnt[1]) {
      cout << t[1].second << " ";
    } else {
      cout << "-1 ";
    }
  }
}
