import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next()
    
    val ss = s.toCharArray
    val left = new Array[Int](n)
    val right = new Array[Int](n)
    for (i <- ss.indices) {
      if (i != 0) {
        ss(i) match {
          case '(' => left(i) = left(i - 1) + 1; right(i) = right(i - 1)
          case ')' => right(i) = right(i - 1) + 1; left(i) = left(i - 1)
        }
      } else {
        ss(i) match {
          case '(' => left(i) = 1; right(i) = 0
          case ')' => left(i) = 0; right(i) = 1
        }
      }
    }
    
    val ds = new Array[Int](n)
    for (i <- ds.indices) {
      ds(i) = left(i) - right(i)
    }
    
    val min = ds.min
    val d = ds(n - 1)
    
    (0 until (-min)).foreach(_ => print('('))
    print(s)
    (0 until (d - min)).foreach(_ => print(')'))
    println()
  }
}