def main(): N = int(input()) S = input() lst = [0] * N dic = dict() stack = [] apnd = stack.append pop_ = stack.pop i = 1 for j, s in enumerate(S): if s == '(': apnd(i) lst[j] = i dic[i] = dic.get(i, []) + [j] i += 1 else: x = pop_() lst[j] = x dic[x] = dic[x] + [j] for i, j in enumerate(lst): a, b = dic[j] x = a ^ b ^ i print(x + 1) main()