import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.Sequence as Seq
import qualified Data.IntSet as IS

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn :: IO Int
    s <- C.getLine
    let lr = C.foldl' (\n c -> if c == '(' then n+1 else max 0 (n-1) ) 0 s
    let rl = C.foldr' (\c n -> if c == ')' then n+1 else max 0 (n-1) ) 0 s
    C.putStrLn $ C.concat [C.replicate rl '(', s, C.replicate lr ')']




