import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val s = in.readLine
  val lf = mu.ListBuffer.empty[Char]
  val lb = mu.ListBuffer.empty[Char]
  val stack = mu.Stack.empty[Char]

  s.foreach { ch =>
    if(ch == '(') stack.push(ch)
    else{
      if(stack.isEmpty) '(' +=: lf
      else stack.pop
    }
  }

  while(stack.nonEmpty) {
    stack.pop
      ')' +=: lb
  }

  val ans = lf ++ s ++ lb.reverse
  println(ans.mkString)
}