a=b=0 l=[] n=gets.to_i gets.chomp.chars{|x|a-=x<')'?1:-1;b0,e>0?d:c-d]}.each{|c,d|b