import Data.List

main = do
 getLine
 as <- getLine
 putStrLn (ins as)

ins as = replicate nbl '(' ++ as ++ replicate nbr ')'
 where
  asum = scanl (\acc c -> if c==')' then acc+1 else acc-1) 0 as
  nbl = maximum asum
  nbr = let (ls,rs) = partition (=='(') as in length ls + nbl - length rs