
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val ign, str = sc.next()
  val sb = new StringBuilder

  val (l, r, cnt) = Range(0, str.length)
    .map(str.charAt)
    .foldLeft((0, 0, 0)) {
      case ((l, r, cnt), c) =>
        (c, cnt) match {
          case ('(', _) =>
            (l + 1, r, cnt + 1)
          case (')', 0) =>
            (l, r + 1, cnt)
          case (')', _) =>
            (l - 1, r, cnt - 1)
        }
    }

  val ans = Stream.concat(Range(0, r).map(_ => '('), str.toStream, Range(0, l).map(_ => ')'))
    .foreach(sb.append)
  println(sb.toString())
}
