object Main extends App {
	var N = scala.io.StdIn.readInt
	val S = scala.io.StdIn.readLine

	def find(x: List[Char]): Array[Int] = {
		val n = x.size
		val a: Array[Int] = new Array(n)

		for(i<- 0 until n){
			for(j <- 0 to i){
				x(j) match {
					case '(' => a(i) = a(i) + 1
					case ')' => a(i) = a(i) - 1
					case _ =>
				}
			}
		}

		return a;
	}

	def tail(x: List[Char], y: Char): List[Char] = {
		var temp: List[Char] = List(y)
		for(i <- x.size - 1 to 0 by -1){
			temp = x(i)::temp
		}
		temp
	}

	var s = S.toList
	var temp = find(s)
	var a = temp.min
	var b = temp(temp.size - 1)

	while(a!=0 && b!=0){
		if(b<0){
			for(i<-0 until -b){
				s = '(' :: s
			}
		}
		if(b>0){
			for(i<- 0 until b){
				s = tail(s, ')')
			}
		}

		temp = find(s)
		a = temp.min
		b = temp(temp.size - 1)
	}

	for(i<- 0 until temp.size){
		print(s(i))
	}

}