#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000005;
int maxi = 1 << 30, mini = -(1 << 30);
struct Node {
  int val, mark;
};
Node preMax[4 * maxN];
Node preMin[4 * maxN];
void build(int k, int arr[], int left, int right) {
  preMax[k].mark = 0;
  preMin[maxN].mark = 0;
  if (left == right) {
    preMax[k].val = arr[left];
    preMin[k].val = arr[left];
  } else {
    int mid = (left + right) / 2;
    build(2 * k + 1, arr, left, mid);
    build(2 * k + 2, arr, mid + 1, right);
    preMax[k].val = max(preMax[2 * k + 1].val, preMax[2 * k + 2].val);
    preMin[k].val = min(preMin[2 * k + 1].val, preMin[2 * k + 2].val);
  }
}
void pushdown(int k) {
  int m = preMax[k].mark;
  if (m != 0) {
    preMax[2 * k + 1].mark += m;
    preMax[2 * k + 1].val += m;
    preMax[2 * k + 2].mark += m;
    preMax[2 * k + 2].val += m;
    preMax[k].mark = 0;
  }
  if ((m = preMin[k].mark) != 0) {
    preMin[2 * k + 1].mark += m;
    preMin[2 * k + 1].val += m;
    preMin[2 * k + 2].mark += m;
    preMin[2 * k + 2].val += m;
    preMin[k].mark = 0;
  }
}
void update(int k, int qstart, int qend, int nstart, int nend, int delta) {
  if (qend < nstart || nend < qstart) return;
  if (qstart <= nstart && nend <= qend) {
    preMax[k].val += delta;
    preMax[k].mark += delta;
    preMin[k].val += delta;
    preMin[k].mark += delta;
    return;
  }
  pushdown(k);
  int mid = (nstart + nend) / 2;
  update(2 * k + 1, qstart, qend, nstart, mid, delta);
  update(2 * k + 2, qstart, qend, mid + 1, nend, delta);
  preMax[k].val = max(preMax[2 * k + 1].val, preMax[2 * k + 2].val);
  preMin[k].val = min(preMin[2 * k + 1].val, preMin[2 * k + 2].val);
}
int rangeMax(int k, int qstart, int qend, int nstart, int nend) {
  if (nend < qstart || qend < nstart) return mini;
  if (qstart <= nstart && nend <= qend) return preMax[k].val;
  pushdown(k);
  int mid = (nstart + nend) / 2;
  int left = rangeMax(2 * k + 1, qstart, qend, nstart, mid);
  int right = rangeMax(2 * k + 2, qstart, qend, mid + 1, nend);
  return max(left, right);
}
int rangeMin(int k, int qstart, int qend, int nstart, int nend) {
  if (nend < qstart || qend < nstart) return maxi;
  if (qstart <= nstart && nend <= qend) return preMin[k].val;
  pushdown(k);
  int mid = (nstart + nend) / 2;
  int left = rangeMin(2 * k + 1, qstart, qend, nstart, mid);
  int right = rangeMin(2 * k + 2, qstart, qend, mid + 1, nend);
  return min(left, right);
}
int main(int arc, char** argv) {
  int n;
  string s;
  cin >> n >> s;
  char rec[n];
  int p = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L')
      p = max(0, p - 1);
    else if (s[i] == 'R')
      p += 1;
    else if (s[i] == '(') {
      if (rec[p] == ')')
        update(0, p, n - 1, 0, n - 1, 2);
      else if (rec[p] != '(')
        update(0, p, n - 1, 0, n - 1, 1);
      rec[p] = '(';
    } else if (s[i] == ')') {
      if (rec[p] == '(')
        update(0, p, n - 1, 0, n - 1, -2);
      else if (rec[p] != ')')
        update(0, p, n - 1, 0, n - 1, -1);
      rec[p] = ')';
    } else {
      if (rec[p] == '(')
        update(0, p, n - 1, 0, n - 1, -1);
      else if (rec[p] == ')')
        update(0, p, n - 1, 0, n - 1, 1);
      rec[p] = '0';
    }
    int min = rangeMin(0, 0, n - 1, 0, n - 1);
    int end = rangeMax(0, n - 1, n - 1, 0, n - 1);
    if (min >= 0 && end == 0) {
      int res = rangeMax(0, 0, n - 1, 0, n - 1);
      cout << res << " ";
    } else
      cout << "-1 ";
  }
  cout << endl;
}
