#include <bits/stdc++.h>
using namespace std;
struct Node {
  int totalSum;
  int maxPrefixSum;
  int maxSuffixSum;
  int maxSubarraySum;
  int minPrefixSum;
  int minSuffixSum;
  int minSubarraySum;
  Node(int value = 0) {
    minPrefixSum = minSuffixSum = minSubarraySum = maxPrefixSum = maxSuffixSum =
        maxSubarraySum = totalSum = value;
  }
  static 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.minSubarraySum,
             leftChild.totalSum + rightChild.minPrefixSum});
    return parentNode;
  }
};
Node t[((int)1e6 + 5) * 2];
int n;
void build() {
  for (int i = 1; i <= 2 * n + 5; i++) t[i] = Node();
}
void update(int p, Node obj) {
  for (t[p += n] = obj; p >>= 1;) t[p] = Node::merge(t[p << 1], t[p << 1 | 1]);
}
Node query(int l, int r) {
  Node retL, retR = Node();
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) retL = Node::merge(retL, t[l++]);
    if (r & 1) retR = Node::merge(t[--r], retR);
  }
  return Node::merge(retL, retR);
}
int main() {
  cin >> n;
  string s;
  cin >> s;
  build();
  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(pos - 1, Node(1));
    } else if (s[i] == ')') {
      update(pos - 1, Node(-1));
    } else {
      update(pos - 1, Node(0));
    }
    Node res = query(0, n);
    if (res.totalSum != 0 || res.minSubarraySum < 0) {
      cout << -1 << " ";
    } else {
      cout << res.maxSubarraySum << " ";
    }
  }
  cout << endl;
}
