object Main extends App {
    
    val sc = new java.util.Scanner(System.in)
    val _ = sc.nextInt
	val str = sc.next
    
    var left_cnt = 0
    var right_cnt = 0
    
    for (s <- str) {
        if (s == '(') {
            left_cnt = left_cnt + 1
        } else {
            if (left_cnt > 0) {
                left_cnt = left_cnt - 1
            } else {
                right_cnt = right_cnt + 1
            }
        }
    }
    
    for (_ <- 0 until right_cnt) {
        print("(")
    }
    print(str)
    for (_ <- 0 until left_cnt) {
        print(")")
    }

    println("")
}