
object MainKt {
  
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val S=readLine()!!
    assert(S.length==N)
    var ins_front=""
   
    var correspond=0
    
    for(i in S.indices) {
      if(S[i]=='(') {
        correspond+=1
      }
      else {
        if(correspond==0) {
          ins_front+="("
        }
        else{
          correspond-=1
        }
      }
    }
     val ins_back=if(correspond==0) {""} else { (1..correspond).map{')'}.joinToString("")}
     println(ins_front+S+ins_back)
  }
}
