main = do
  _ <- getLine
  s <- getLine

  let countLR (c:cs) nl nr | c == '('           = countLR cs (nl+1) nr
                           | c == ')' && nl > 0 = countLR cs (nl-1) nr
                           | otherwise          = countLR cs nl (nr+1)
      countLR []     nl nr = (nl, nr)

      (nl, nr) = countLR s 0 0

  putStr $ replicate nr '('
  putStr s
  putStrLn $ replicate nl ')'