"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    let leftCnt  = 0;
    let rightCnt = 0;
    
    for(let i in S) {
        if(S[i] === ")" && leftCnt) {
            leftCnt--;
        } else if (S[i] === ")") {
            rightCnt++;
        }
        
        if(S[i] === "(") {
            leftCnt++;
        }
    }
    
    for(let i=0; i<rightCnt; i++) {
        S.unshift("(");
    }
    
    for(let i=0; i<leftCnt; i++) {
        S.push(")");
    }
    
    console.log(S.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));