#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int M = 30000;
const long long base = 137;
const long long mod = 1000000007LL;
struct Node {
  int sum, suml, sumr, peak;
  Node() : sum(0), suml(0), sumr(0), peak(0) {}
} IT[4 * N];
void update(int k, int l, int r, int pos, int val) {
  if (l > pos || r < pos) return;
  if (l == r) {
    IT[k].sum = IT[k].suml = IT[k].sumr = IT[k].peak = 0;
    IT[k].sum = IT[k].peak = val;
    if (val == 1)
      IT[k].sumr = 1;
    else if (val == -1)
      IT[k].suml = 1;
    return;
  }
  int mid = (l + r) >> 1;
  update((k << 1), l, mid, pos, val);
  update(((k << 1) + 1), mid + 1, r, pos, val);
  IT[k].sum = IT[(k << 1)].sum + IT[((k << 1) + 1)].sum;
  int tmp = min(IT[(k << 1)].sumr, IT[((k << 1) + 1)].suml);
  IT[k].suml = IT[(k << 1)].suml + IT[((k << 1) + 1)].suml - tmp;
  IT[k].sumr = IT[((k << 1) + 1)].sumr + IT[(k << 1)].sumr - tmp;
  IT[k].peak =
      max(IT[(k << 1)].peak, IT[(k << 1)].sum + IT[((k << 1) + 1)].peak);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  string s;
  cin >> n;
  cin >> s;
  s = ' ' + s;
  int pos = 1;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'L') {
      --pos;
      if (pos == 0) ++pos;
    } else if (s[i] == 'R') {
      ++pos;
    } else if (s[i] == '(') {
      update(1, 1, n, pos, 1);
    } else if (s[i] == ')') {
      update(1, 1, n, pos, -1);
    } else {
      update(1, 1, n, pos, 0);
    }
    if (IT[1].suml + IT[1].sumr != 0)
      cout << -1 << ' ';
    else
      cout << IT[1].peak << ' ';
  }
  return 0;
}
