import Control.Monad
import Data.Maybe
import Data.Char
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntN n = map readInt <$> replicateM (fromIntegral n) BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents


main = do
  _ <- getInt
  s <- getLine

  let countBrackets (x:rest)  bl br | x == '('           =  countBrackets rest (bl+1) br
                                    | x == ')' && bl > 0 =  countBrackets rest (bl-1) br
                                    | otherwise          =  countBrackets rest bl (br+1)
      countBrackets []        bl br = (bl, br)
      (bl,br) = countBrackets s 0 0

  putStr $ replicate br '('
  putStr s
  putStrLn $ replicate bl ')'