import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, s) = (sc.nextInt, sc.next.toCharArray)
  val (res, sta) = s.foldLeft(("", 0)) { case ((str, stack), next) =>
    next match {
      case '('               => (str + "(", stack + 1)
      case ')' if stack == 0 => (str + "()", stack)
      case _                 => (str + ")", stack - 1)
    }
  }
  println(s"$res${")" * sta}")
}
