#include <bits/stdc++.h>
using namespace std;
struct Node {
  int totalSum;
  int maxPrefixSum;
  int maxSuffixSum;
  int maxSubarraySum;
  int minPrefixSum;
  int minSuffixSum;
  int minSubarraySum;
  Node() {
    minPrefixSum = minSuffixSum = minSubarraySum = maxPrefixSum = maxSuffixSum =
        maxSubarraySum = totalSum = 0;
  }
  Node(int value) {
    minPrefixSum = minSuffixSum = minSubarraySum = maxPrefixSum = maxSuffixSum =
        maxSubarraySum = totalSum = value;
  }
};
int n;
Node t[4 * (int)1e6 + 5];
Node merge(Node leftChild, Node rightChild) {
  Node parentNode;
  parentNode.totalSum = leftChild.totalSum + rightChild.totalSum;
  parentNode.maxPrefixSum =
      max(leftChild.maxPrefixSum, leftChild.totalSum + rightChild.maxPrefixSum);
  parentNode.maxSuffixSum = max(rightChild.maxSuffixSum,
                                rightChild.totalSum + leftChild.maxSuffixSum);
  parentNode.maxSubarraySum =
      max({leftChild.maxSubarraySum, rightChild.maxSubarraySum,
           leftChild.maxSuffixSum + rightChild.maxPrefixSum});
  parentNode.minPrefixSum =
      min(leftChild.minPrefixSum, leftChild.totalSum + rightChild.minPrefixSum);
  parentNode.minSuffixSum = min(rightChild.minSuffixSum,
                                rightChild.totalSum + leftChild.minSuffixSum);
  parentNode.minSubarraySum = min(
      {leftChild.minPrefixSum, leftChild.totalSum + rightChild.minPrefixSum});
  return parentNode;
}
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = Node();
  } else {
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = merge(t[v * 2], t[v * 2 + 1]);
  }
}
Node sum(int v, int tl, int tr, int l, int r) {
  if (l > r) return Node();
  if (l == tl && r == tr) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  return merge(sum(v * 2, tl, tm, l, min(r, tm)),
               sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
  if (tl == tr) {
    t[v] = Node(new_val);
  } else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = merge(t[v * 2], t[v * 2 + 1]);
  }
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  build(1, 0, n);
  string cur;
  int pos = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      pos++;
    else if (s[i] == 'L')
      pos = max(1, pos - 1);
    else if (s[i] == '(') {
      update(1, 0, n, pos - 1, 1);
    } else if (s[i] == ')') {
      update(1, 0, n, pos - 1, -1);
    } else {
      update(1, 0, n, pos - 1, 0);
    }
    Node res = sum(1, 0, n, 0, n);
    if (res.totalSum != 0 || res.minSubarraySum < 0) {
      cout << -1 << " ";
    } else {
      cout << res.maxSubarraySum << " ";
    }
  }
  cout << endl;
}
