import qualified Data.ByteString.Char8 as B

main = getLine >> B.getLine >>= B.putStrLn . solve

solve :: B.ByteString -> B.ByteString
solve xs = B.replicate l '(' `B.append` xs `B.append` B.replicate r ')'
    where
        (l, r) = B.foldl' ff (0, 0) xs
        ff (lacc, racc) x
            | x == '(' = (lacc, racc + 1)
            | racc > 0 = (lacc, racc - 1)
            | otherwise = (lacc + 1, racc)
