#include <bits/stdc++.h>
using namespace std;
struct tree {
  int mx, mn, tag;
};
tree t[4 * 1000003];
void update(int val, int l, int r, int start, int end, int n) {
  if (t[n].tag != 0) {
    t[n].mx += t[n].tag;
    t[n].mn += t[n].tag;
    if (start != end) {
      t[2 * n].tag += t[n].tag;
      t[2 * n + 1].tag += t[n].tag;
    }
    t[n].tag = 0;
  }
  if (start > end || start > r || end < l) return;
  if (start >= l && end <= r) {
    t[n].mx += val;
    t[n].mn += val;
    if (start != end) {
      t[2 * n].tag += val;
      t[2 * n + 1].tag += val;
    }
    return;
  }
  int mid = (start + end) / 2;
  update(val, l, r, start, mid, 2 * n);
  update(val, l, r, mid + 1, end, 2 * n + 1);
  t[n].mx = max(t[2 * n].mx + t[2 * n].tag, t[2 * n + 1].mx + t[2 * n + 1].tag);
  t[n].mn = min(t[2 * n].mn + t[2 * n].tag, t[2 * n + 1].mn + t[2 * n + 1].tag);
}
int last(int l, int r, int L, int R, int n) {
  if (l == L && r == R) return t[n].mn + t[n].tag;
  t[n].mx += t[n].tag;
  t[n].mn += t[n].tag;
  if (L != R) {
    t[2 * n].tag += t[n].tag;
    t[2 * n + 1].tag += t[n].tag;
  }
  t[n].tag = 0;
  int m = (L + R) / 2;
  if (r <= m) return last(l, r, L, m, 2 * n);
  if (l > m) return last(l, r, m + 1, R, 2 * n + 1);
  return min(last(l, m, L, m, 2 * n), last(m + 1, r, m + 1, R, 2 * n + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int pos = 0;
  int ans[n];
  char cur[n + 1];
  for (int i = 0; i < n + 1; i++) cur[i] = ' ';
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R')
      pos++;
    else if (s[i] == 'L')
      pos = max(0, pos - 1);
    else {
      if (cur[pos] == '(') {
        if (s[i] == ')')
          update(-2, pos, n - 1, 0, n - 1, 1);
        else if (s[i] != '(')
          update(-1, pos, n - 1, 0, n - 1, 1);
      } else if (cur[pos] == ')') {
        if (s[i] == '(')
          update(2, pos, n - 1, 0, n - 1, 1);
        else if (s[i] != ')')
          update(1, pos, n - 1, 0, n - 1, 1);
      } else {
        if (s[i] == '(') {
          update(1, pos, n - 1, 0, n - 1, 1);
        } else if (s[i] == ')') {
          update(-1, pos, n - 1, 0, n - 1, 1);
        }
      }
      cur[pos] = s[i];
    }
    if (t[1].mn + t[1].tag != 0 || last(n - 1, n - 1, 0, n - 1, 1) != 0)
      ans[i] = -1;
    else
      ans[i] = t[1].mx + t[1].tag;
  }
  for (int i = 0; i < s.size(); i++) cout << ans[i] << " ";
  cout << "\n";
}
