import Data.List

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

ins as = replicate nbr '(' ++ as ++ replicate nbl ')'
 where
  nbr = let (br,bl) = partition (==')') $ reverse $ dropWhile (=='(') $ reverse as
         in length br - length bl
  nbl = let (bl,br) = partition (=='(') $ dropWhile (==')') as
         in length bl - length br