main :: IO ()
main = do
    _ <- getLine
    s <- getLine
    putStrLn $ solve s

-- |
--
-- >>> solve ")))())"
-- "(((()))())"
--
-- >>> solve "))))(((("
-- "(((())))(((())))"
--
-- >>> solve "()(()))"
-- "(((())))(((())))"
solve :: String -> String
solve s = replicate a '(' ++ s ++ replicate b ')'
  where
    a = negate $ min (minimum xs) 0
    b = last xs + a
    xs = f s

f :: String -> [Int]
f s = scanl1 (+) (map toNum s)

toNum :: Char -> Int
toNum '(' =  1
toNum ')' = -1
toNum _ = undefined
