#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int niz[maxn + 20], n;
string s;
int maxx[maxn * 4], minn[maxn * 4], sum, lazy[maxn * 4];
void check() {
  if (sum != 0) {
    printf("-1 ");
    return;
  }
  if (minn[1] < 0) {
    printf("-1 ");
    return;
  }
  printf("%d ", maxx[1]);
}
void push(int x) {
  if (lazy[x] == 0) return;
  maxx[x * 2] += lazy[x];
  maxx[x * 2 + 1] += lazy[x];
  minn[x * 2] += lazy[x];
  minn[x * 2 + 1] += lazy[x];
  lazy[x * 2] += lazy[x];
  lazy[x * 2 + 1] += lazy[x];
  lazy[x] = 0;
}
void update(int x, int l, int r, int ll, int val) {
  if (l >= ll) {
    lazy[x] += val;
    maxx[x] += val;
    minn[x] += val;
    return;
  }
  push(x);
  int mid = (l + r) / 2;
  if (mid < ll)
    update(x * 2 + 1, mid + 1, r, ll, val);
  else {
    update(x * 2 + 1, mid + 1, r, ll, val);
    update(x * 2, l, mid, ll, val);
  }
  maxx[x] = max(maxx[x * 2], maxx[x * 2 + 1]);
  minn[x] = min(minn[x * 2], minn[x * 2 + 1]);
}
int main() {
  scanf("%d", &n);
  cin >> s;
  int curr = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      if (curr == 1) {
      } else
        curr--;
      check();
    } else if (s[i] == 'R') {
      curr++;
      check();
    } else {
      if (s[i] == '(' || s[i] == ')') {
        if (s[i] == '(') {
          update(1, 1, n, curr, 1 - niz[curr]);
          sum = sum + 1 - niz[curr];
          niz[curr] = 1;
        } else {
          update(1, 1, n, curr, -1 - niz[curr]);
          sum = sum - 1 - niz[curr];
          niz[curr] = -1;
        }
        check();
      } else {
        update(1, 1, n, curr, 0 - niz[curr]);
        sum = sum + 0 - niz[curr];
        niz[curr] = 0;
        check();
      }
    }
  }
  return 0;
}
