from collections import deque

n = int(input())
sq = list(input())

outls = [0 for i in range(n)]
tmpls = []
for i in range(len(sq)):
    if sq[i] == '(':
        tmpls.append(i)
    else:
        j = tmpls.pop()
        outls[j] = i+1
        outls[i] = j+1
        
for i in outls:
    print(i)