import kotlin.math.min

fun main() {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    var r = 0
    var l = Int.MAX_VALUE
    s.forEach {
        if (it == '(') {
            r++
        } else {
            r--
        }
        l = min(r, l)
    }
    if (l > 0) {
        l = 0
    }
    val rs = ")".repeat(r - l)
    val ls = "(".repeat(-l)
    println("$ls$s$rs")
}
