l=[] n=int(input()) d={i:0 for i in range(1,n+1)} s=input() for i in range(1,n+1): if s[i-1]=="(": l.append(i) else: d[l[-1]],d[i]=i,l[-1] l.pop() print(*d.values(),sep="\n")