
remover::String -> String
remover []  =[]
remover (x:[])=[x]
remover (x:y:r)= if (x=='(')&&(y==')') then remover r else x:(remover (y:r))

mult_remover::String -> Int -> String
mult_remover st 0 = st
mult_remover st n = mult_remover (remover st) (n-1)

solver::String->String
solver st = let (par,chl) =span (\x->x==')') (mult_remover st 50) in
            let (p,c)=(length par,length chl)in
            (replicate p '(')++st++(replicate c ')')

main::IO()
main=do
  _<-getLine
  dat<-getLine
  putStr (solver dat)
  putStr "\n"