solve :: String -> String
solve s = replicate r0 '(' ++ s ++ replicate l0 ')'
    where
        sol l r "" = (l, r)
        sol l r (c : cs)
            | c == '(' = sol (l + 1) r cs
            | l == 0 = sol l (r + 1) cs
            | otherwise = sol (l - 1) r cs
        (l0, r0) = sol 0 0 s

main :: IO ()
main = getLine >> getLine >>= putStrLn . solve
