import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 文字列の入力
    n <- getLine
    s <- getLine
    let fstr = takeWhile (== ')') s
        rest = dropWhile (== ')') s
        fsts = replicate (length fstr) '('
        diff = foldl (\acc c -> if c == '(' then succ acc else pred acc) 0 rest
    if diff == 0
        then putStrLn $ fsts ++ s
        else if diff > 0
            then putStrLn $ fsts ++ s ++ replicate diff ')'
            else putStrLn $ fsts ++ replicate (abs diff) '(' ++ s
