import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next()
    val sum = s
      .map {
        case c if c == '(' => 1
        case _             => -1
      }
      .scan(0)(_ + _)
    val min = sum.min
    (1 to (-min)).foreach(_ => print('('))
    print(s)
    (1 to  (sum.last - min)).foreach(_ => print(')'))
    println()
  }
}
