#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, st1[4 * N], st2[4 * N], lazy[4 * N], a[N];
string s;
void push_down(int id, int l, int r) {
  if (lazy[id] != 0) {
    st1[id] += lazy[id];
    st2[id] += lazy[id];
    if (l < r) {
      lazy[id << 1] += lazy[id];
      lazy[id << 1 | 1] += lazy[id];
    }
    lazy[id] = 0;
  }
}
void update(int id, int l, int r, int i, int j, int x) {
  push_down(id, l, r);
  if (l > j || r < i || i > j) {
    return;
  }
  if (l >= i && r <= j) {
    st1[id] += x;
    st2[id] += x;
    if (l < r) {
      lazy[id << 1] += x;
      lazy[id << 1 | 1] += x;
    }
    return;
  }
  int mid = (l + r) >> 1;
  update(id << 1, l, mid, i, j, x);
  update(id << 1 | 1, mid + 1, r, i, j, x);
  st1[id] = max(st1[id << 1], st1[id << 1 | 1]);
  st2[id] = min(st2[id << 1], st2[id << 1 | 1]);
}
int get(int id, int l, int r, int i) {
  push_down(id, l, r);
  if (l == r) {
    return st1[id];
  } else {
    int mid = (l + r) >> 1;
    if (i <= mid) {
      return get(id << 1, l, mid, i);
    } else {
      return get(id << 1 | 1, mid + 1, r, i);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  s = " " + s;
  int ptr = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'L') {
      if (ptr > 1) ptr--;
    } else if (s[i] == 'R') {
      ptr++;
    } else if (s[i] == '(') {
      update(1, 1, n, ptr, n, -a[ptr] + 1);
      a[ptr] = 1;
    } else if (s[i] == ')') {
      update(1, 1, n, ptr, n, -a[ptr] - 1);
      a[ptr] = -1;
    } else {
      update(1, 1, n, ptr, n, -a[ptr]);
      a[ptr] = 0;
    }
    if (get(1, 1, n, n) == 0 && st2[1] >= 0) {
      cout << st1[1] << " ";
    } else {
      cout << "-1 ";
    }
  }
}
