n = int(input()) s = input() ans = [0] * n stack = [] for i in range(n): if s[i] == "(": stack.append(i) elif s[i] == ")": t = stack.pop() ans[i] = t ans[t] = i for a in ans: print(a+1)