N=gets.to_i
st=[]
corr=[]
gets.chomp.each_char.with_index{|c, i|
    if c=='('
        st.push(i)
    else
        j = st.pop()
        corr[j] = i;
        corr[i] = j;
    end
}
corr.each_with_index{|v, i|
    puts v+1
}