#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 20;
int tree[2 * MAXN];
int tree_min[2 * MAXN];
int tree_max[2 * MAXN];
void update(int v, int vl, int vr, int tl, int tr, int val) {
  if (vl > tr || tl > vr) {
    return;
  }
  if (tl <= vl && tr >= vr) {
    tree[v] += val;
    return;
  }
  int vm = (vl + vr) / 2;
  tree[2 * v] += tree[v];
  tree[2 * v + 1] += tree[v];
  tree[v] = 0;
  update(2 * v, vl, vm, tl, tr, val);
  update(2 * v + 1, vm + 1, vr, tl, tr, val);
  tree_max[v] =
      max(tree_max[2 * v] + tree[2 * v], tree_max[2 * v + 1] + tree[2 * v + 1]);
  tree_min[v] =
      min(tree_min[2 * v] + tree[2 * v], tree_min[2 * v + 1] + tree[2 * v + 1]);
}
void update(int pos, int val) { update(1, 0, MAXN - 1, pos, MAXN - 1, val); }
int get_min() { return tree_min[1] + tree[1]; }
int get_max() { return tree_max[1] + tree[1]; }
int get_val(char f, char s) {
  int val = 0;
  if (f == '(') {
    --val;
  }
  if (f == ')') {
    ++val;
  }
  if (s == '(') {
    ++val;
  }
  if (s == ')') {
    --val;
  }
  return val;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string current;
  for (int i = 0; i < n; ++i) {
    current.push_back('A');
  }
  int pos = 0;
  int balance = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      ++pos;
    } else if (s[i] == 'L') {
      if (pos > 0) {
        --pos;
      }
    } else {
      update(pos, get_val(current[pos], s[i]));
      balance += get_val(current[pos], s[i]);
      current[pos] = s[i];
    }
    if (balance != 0 || get_min() <= -1) {
      cout << -1;
    } else {
      cout << get_max();
    }
    cout << " ";
  }
}
