import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{min, max, abs}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val S = sc.next

    sealed trait Part
    case class Left(v: Int) extends Part
    case class Right(v: Int) extends Part
    case class Pair(l: Int, r: Int)

    def step(cs: List[Char], pre: Char, cnt: Int, acc: List[Part]): List[Part] = {
      def mkPart = pre match {
        case '(' => Left(cnt)
        case ')' => Right(cnt)
      }

      cs match {
        case Nil => mkPart :: acc
        case c :: remain =>
          c match {
            case `pre` => step(remain, c, cnt + 1, acc)
            case _ => step(remain, c,1, mkPart :: acc)
          }
      }
    }

    val parts = step(S.drop(1).toCharArray.toList, S.charAt(0), 1, Nil).reverse

    def step1(ps: List[Part], left: Option[Left], acc: List[Pair]): List[Pair] = ps match {
      case Nil => left match {
        case None => acc
        case Some(Left(l)) => Pair(l, 0) :: acc
      }
      case Right(r) :: remain =>
        val l = left.map(_.v) getOrElse 0
        step1(remain, None, Pair(l, r) :: acc)

      case (l: Left) :: remain =>
        step1(remain, Some(l), acc)

    }

    val pairs = step1(parts, None, Nil).reverse

    var r = 0 // )の数
    var l = 0 // (の数
    pairs foreach { p =>
      if (p.l > p.r) {
        l += p.l - p.r
      } else if (p.r > p.l) {
        val r0 = p.r - p.l
        if (r0 > l) {
          r += r0 - l
          l = 0
        } else {
          l -= r0
        }
      }
    }
    println("(" * r + S + ")" * l)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}
