#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 100;
class SegmentTree {
 private:
  const long long INF = 1e18;
  struct Node {
    long long mx, mn;
    long long add;
  };
  vector<Node> tree;
  int n;
  void add(int v, int L, int R, int l, int r, long long val) {
    if (l > r) {
      return;
    }
    if (L == l && R == r) {
      tree[v].add += val;
    } else {
      int mid = L + (R - L) / 2;
      add(2 * v + 1, L, mid, l, min(mid, r), val);
      add(2 * v + 2, mid + 1, R, max(mid + 1, l), r, val);
      tree[v].mx = max(tree[2 * v + 1].mx + tree[2 * v + 1].add,
                       tree[2 * v + 2].mx + tree[2 * v + 2].add);
      tree[v].mn = min(tree[2 * v + 1].mn + tree[2 * v + 1].add,
                       tree[2 * v + 2].mn + tree[2 * v + 2].add);
    }
  }
  long long getMin(int v, int L, int R, int l, int r) {
    if (l > r) {
      return INF;
    }
    if (L == l && R == r) {
      return tree[v].mn + tree[v].add;
    }
    int mid = L + (R - L) / 2;
    return tree[v].add + min(getMin(2 * v + 1, L, mid, l, min(mid, r)),
                             getMin(2 * v + 2, mid + 1, R, max(l, mid + 1), r));
  }
  long long getMax(int v, int L, int R, int l, int r) {
    if (l > r) {
      return -INF;
    }
    if (L == l && R == r) {
      return tree[v].mx + tree[v].add;
    }
    int mid = L + (R - L) / 2;
    return tree[v].add + max(getMax(2 * v + 1, L, mid, l, min(mid, r)),
                             getMax(2 * v + 2, mid + 1, R, max(l, mid + 1), r));
  }

 public:
  void init(int sz) {
    n = sz;
    tree.resize(4 * n, {0, 0, 0});
  }
  void add(int l, int r, long long val) { add(0, 0, n - 1, l, r, val); }
  long long getMin(int l, int r) { return getMin(0, 0, n - 1, l, r); }
  long long getMax(int l, int r) { return getMax(0, 0, n - 1, l, r); }
};
int n;
int val[MAXN];
string s;
int pos;
SegmentTree tree;
int main() {
  scanf("%d\n", &n);
  getline(cin, s);
  pos = 0;
  tree.init(n);
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == 'L') {
      if (pos > 0) pos--;
    } else if (s[i] == 'R') {
      pos++;
    } else {
      int newVal = 0;
      if (s[i] == '(') {
        newVal = 1;
      } else if (s[i] == ')') {
        newVal = -1;
      }
      int delta = newVal - val[pos];
      val[pos] = newVal;
      tree.add(pos, n - 1, delta);
    }
    int mn = tree.getMin(0, n - 1);
    int lastVal = tree.getMin(n - 1, n - 1);
    if (mn < 0 || lastVal != 0) {
      printf("%d ", -1);
    } else {
      printf("%lld ", tree.getMax(0, n - 1));
    }
  }
  cout << endl;
  return 0;
}
