main = do
  getLine
  s <- getLine
  putStr . sol $ s

cb = length . filter (=='(')
ck = length . filter (==')')

pb 0 s = s
pb n s = "(" ++ (pb (n-1) s)

pk 0 s = s
pk n s = (pk (n-1) s) ++ ")"

rb [] = 0
rb (x:xs)
  | x == '(' = 1 + rb xs
  | otherwise = rb xs

rk [] = 0
rk s
  | last s == ')' = 1 + rk . init $ s
  | otherwise = rk . init $ s
  
sol s
  | cb == ck 
  

