main = do
    getLine
    s <- getLine
    let (l,r) = solve (0,0) s
    putStrLn $ replicate r '(' ++ s ++ replicate l ')'

solve (l,r) [] = (l,r)
solve (l,r) (c:cs) | c == '(' = solve (l+1,r) cs
                   | c == ')' = solve (if l > 0 then (l-1,r) else (l,r+1)) cs