N = int(input()) S = list(input()) bras = [] ans = {} for i in range(N): if S[i] == '(': bras.append(i+1) elif S[i] == ')': ans[bras[-1]] = i+1 ans[i+1] = bras[-1] bras.pop(-1) for i in range(1, N+1): print(ans[i])