process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function(chunk){
    var lines = chunk.toString().split("\n");
    var num = lines[0];
    var str = lines[1];

    var num_1 = 0;
    var num_2 = 0;

    for(var i= 0; i<str.length; i++){
        if(str[i] === "("){
            num_1 += 1;
        }else{
            num_1 -= 1;
        }

        if(num_1<0){
            num_1 ++; num_2 ++;

        }
    }
    
        var ary_1 = new Array(num_1); //対がない(の数
        var ary_2 = new Array(num_2); //対がない)の数
        //console.log(ary_1);
        //console.log(ary_2);
        
        ary_1.fill(")");
        ary_2.fill("(");

//対になっていない括弧を補足。前に"("、後に")"を付け足す
        var ansAry = ary_2.concat(str);
        //console.log(ansAry);
        ansAry = ansAry.concat(ary_1);
        //console.log(ansAry);

//配列を文字列に変換
        var ans = ansAry.join("");
        console.log(ans);
});
