if __name__ == "__main__": n = int(input()) pre_str = input() pre_res = [0 for i in range(n)] pre_stack = [] for i in range(n): if pre_str[i] == "(": pre_stack.append(i) else: res = pre_stack.pop() pre_res[res] = i pre_res[i] = res for num in pre_res: print(num + 1)