from collections import defaultdict as dd d=dd(int) l=[] n=int(input()) for i,j in enumerate(input(),start=1): if not l: l.append((i,j)) else: a,b=l[-1] if b=="(" and j==")": d[a],d[i]=i,a l.pop() else: l.append((i,j)) for i in range(1,n+1): print(d[i])