N = int(input()) S = input() l = [0] * N stack = [] for i in range(S): if S[i] == '(': stack.append(i) else: j = stack.pop() l[i] = j l[j] = i for i in l: print(i + 1)