n=int(input()) s=input() a=[0]*n q=[] for i in range(n): c=s[i] if s[i]=="(": q+=[i] else: a[q[-1]]=i+1 a[i]=q[-1]+1 q.pop() print(*a,sep="\n")