#include <bits/stdc++.h>
using namespace std;
struct Tree {
  struct Node {
    int mn, mx, add;
  };
  static const int INF = (int)1e9;
  static Node *_t;
  static int _last, _first, _x;
  int n;
  Node *t;
  Tree(int power) : n(1 << power), t(new Node[1 << (power + 1)]) {}
  ~Tree() { delete[] t; }
  static void _add(int i, int tl, int tr) {
    if (tr <= tl || _last <= tl || tr <= _first) {
      return;
    }
    if (_first <= tl && tr <= _last) {
      _t[i].add += _x;
    } else {
      int m = (tl + tr) >> 1;
      _add(2 * i + 0, tl, m);
      _add(2 * i + 1, m, tr);
      int a = _t[2 * i + 0].add, b = _t[2 * i + 1].add;
      _t[i].mn = min(_t[2 * i + 0].mn + a, _t[2 * i + 1].mn + b);
      _t[i].mx = max(_t[2 * i + 0].mx + a, _t[2 * i + 1].mx + b);
    }
  }
  void add(int first, int last, int x) {
    _t = t, _first = first, _last = last, _x = x;
    _add(1, 0, n);
  }
  static int _min(int i, int tl, int tr) {
    if (tr <= tl || _last <= tl || tr <= _first) {
      return +INF;
    }
    if (_first <= tl && tr <= _last) {
      return _t[i].mn + _t[i].add;
    } else {
      int m = (tl + tr) >> 1;
      int v1 = _min(2 * i + 0, tl, m);
      int v2 = _min(2 * i + 1, m, tr);
      return min(v1, v2) + _t[i].add;
    }
  }
  int get_min(int first, int last) {
    _t = t, _first = first, _last = last;
    return _min(1, 0, n);
  }
  static int _max(int i, int tl, int tr) {
    if (tr <= tl || _last <= tl || tr <= _first) {
      return -INF;
    }
    if (_first <= tl && tr <= _last) {
      return _t[i].mx + _t[i].add;
    } else {
      int m = (tl + tr) >> 1;
      int v1 = _max(2 * i + 0, tl, m);
      int v2 = _max(2 * i + 1, m, tr);
      return max(v1, v2) + _t[i].add;
    }
  }
  int get_max(int first, int last) {
    _t = t, _first = first, _last = last;
    return _max(1, 0, n);
  }
};
Tree::Node *Tree::_t;
int Tree::_last, Tree::_first, Tree::_x;
int main() {
  Tree t(20);
  int n;
  static char s[1 << 20];
  scanf("%d%s", &n, s);
  long st = clock();
  string typed(t.n, ' ');
  int pos = 0, sum = 0;
  for (char c : s) {
    if (!c) {
      break;
    } else if (c == 'L') {
      pos = max(0, pos - 1);
    } else if (c == 'R') {
      pos += 1;
    } else {
      int diff = 0;
      if (typed[pos] == '(') {
        diff += -1;
      } else if (typed[pos] == ')') {
        diff += +1;
      }
      if (c == '(') {
        diff += +1;
      } else if (c == ')') {
        diff += -1;
      }
      typed[pos] = c;
      t.add(pos, t.n, diff);
      sum += diff;
    }
    if (t.get_min(0, t.n) < 0 || sum != 0) {
      printf("-1 ");
    } else {
      printf("%d ", t.get_max(0, t.n));
    }
  }
  printf("\n");
  cerr << (clock() - st) / 1000.0 << endl;
  return 0;
}
