import Control.Applicative( (<$>))

main = do
    _n <- getLine
    s_ <- getLine
    let
	proc1 v diff []	= (v,diff)
	proc1 v diff (c:cs)
	  | c==')'	    = if diff==0
				then proc1 ('(':v) diff cs
				else proc1 v (diff-1) cs
	  | otherwise	    = proc1 v (diff+1) cs

	(v,d) = proc1 [] 0 s_
	post = take d $ repeat ')'

    putStr $ v++s_++post