#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        string S; cin >> S;
        stack<int> stk;
        vector<int> res(N);
        rep(i, N) {
            if(S[i] == '(') stk.push(i);
            else {
                int p = stk.top(); stk.pop();
                res[p] = i + 1;
                res[i] = p + 1;
            }
        }
        rep(i, N) cout << res[i] << endl;
        return 0;
    }
};

int main() {
    Solver s;
    s.solve();
    return 0;
}