-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = putStrLn . solve . head . tail . lines =<< getContents

countOp c [] = c
countOp c ('(':s) = countOp (c + 1) s
countOp c (')':s) = countOp (c - 1) s

countCl c [] = c
countCl c (')':s) = countCl (c + 1) s
countCl c ('(':s) = countCl (c - 1) s

solve s = answer where
    op = max 0 $ countOp 0 s
    cl = max 0 $ countCl 0 $ reverse s
    answer = replicate cl '(' ++ s ++ replicate op ')'
