n = int(input()) s = input() al = list(range(n)) stack = [] for (i,c) in enumerate(s) : if c == '(' : stack.append(i) else : j = stack.pop() al[j] = i+1 al[i] = j+1 print('\n'.join(map(str, al)))