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
    
    var strings = Seq.empty[Array[Char]]
    var str = Seq.empty[Char]
    for (i <- ss.indices) {
      if (i == 0) {
        str = str :+ ss(i)
      } else if (ss(i - 1) == ')' && ss(i) == '(') {
        strings = strings :+ str.toArray
        str = Seq.empty :+ s(i)
      } else {
        str = str :+ ss(i)
      }
    }
    strings = strings :+ str.toArray
    
    val (a, b) = strings.map(f).foldLeft((0, 0))((acc, a) => (acc, a) match {
      case ((aa, bb), (a, b)) => (aa + a, bb + b)
    })
    
    (0 until a).foreach(_ => print('('))
    strings.foreach(a => a.foreach(print))
    (0 until b).foreach(_ => print(')'))
  }
  
  def f(s: Array[Char]): (Int, Int) = {
    val left = s.count(x => x == '(')
    val right = s.count(x => x == ')')
    
    if (left > right) {
      (0, left - right)
    } else {
      (right - left, 0)
    }
  }
}