N = int(input()) S = input() a = [0] * N stk = list() for i in range(N): if S[i] == '(': stk.append(i) else: v = stk.pop() a[v] = i a[i] = v for v in a: print(v+1)