import qualified Data.ByteString.Char8 as B
main=getLine>>B.getLine>>=B.putStrLn.f
f xs=B.replicate l '('`B.append`xs`B.append`B.replicate r ')'where(l,r)=B.foldl' h(0,0)xs
h(l,r)x
 |x=='('=(l,r+1)
 |r>0=(l,r-1)
 |otherwise=(l+1,r)