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_2 +=1;
        }
    
        var aryAns = new Array(Math.abs(num_1-num_2));
        
        if(num_1>num_2){
            aryAns.fill(")");
            ans = str.concat(aryAns);
        }else{
            aryAns.fill("(");
            ans = aryAns.concat(str);
        }
    }
    
    var answer = ans.join("");
    console.log(answer);
});
