N = int(input()) S = input().rstrip() A = [0] * N D = {} cnt = 0 for i in range(N): if S[i] == "(": D[cnt] = i cnt += 1 else: cnt -= 1 A[i] = D[cnt] A[D[cnt]] = i for i in range(N): print(A[i] + 1)