main = do
  getLine
  s <- getLine
  putStr . g . f $ s

f [] = []
f (x:xs)
  | x == '(' = f xs
  | x == ')' = "()" ++ f xs

g [] = []
g xs
  | last xs == '(' = g (init xs) ++ "()"
  | last xs == ')' = g (init xs)

