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 diff = foldl (\acc c -> if c == '(' then succ acc else pred acc) 0 s
    if diff == 0
        then putStrLn s
        else if diff > 0
            then putStrLn $ s ++ replicate diff ')'
            else putStrLn $ replicate (abs diff) '(' ++ s
