fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val deque = java.util.ArrayDeque<Char>()
    var openBracket = 0
    S.forEach { s ->
        when (s) {
            '(' -> {
                deque.addLast('(')
                openBracket += 1
            }
            ')' -> {
                if (openBracket > 0) openBracket -= 1
                else deque.addFirst('(')
                deque.addLast(')')
            }
        }
    }

    repeat(openBracket) {
        deque.addLast(')')
    }
    println(deque.joinToString(""))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}
