
import java.util.Scanner

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

  val n = sc.nextInt()
  val 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 match {
          case '(' =>
            (l + 1, r, cnt + 1)
          case ')' =>
            if (cnt == 0) {
              (l, r + 1, cnt)
            } else {
              (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())
}
