object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = sc.next()
  var count = 0
  var a = 0
  for (c <- s) {
    if (c == '(') {
      count += 1
    } else {
      count -= 1
      if (count < 0) {
        a = a.max(count.abs)
      }
    }
  }
  val b = count + a
  println(s"${"("*a}$s${")"*b}")
}
