#include using namespace std; int n; char c[200005]; int cr[200005]; int main() { cin >> n >> c; for (int i = 0; i < n; i++) { if (c[i] == '(') { int rc = 1, kc = 0; while (cr[i] == 0) { if (c[i + rc] == ')') { if (kc == 0) { cr[i] = i + rc + 1; cr[i + rc] = i + 1; } else { kc--; rc++; } } else { rc++; kc++; } } } } for (int i = 0; i < n; i++) cout << cr[i] << endl; }