"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const S = arg[1].split("");
    
    let left  = [];
    let right = [];
    
    for(let i in S) {
        if(S[i] === "(") {
            left.push(1);
        }
        
        if(S[i] === ")") {
            if(left.length) {
                left.pop();
            } else {
                right.push(1);
            }
        }
    }
    
    for(let i in right) {
        S.unshift("(")
    }
    
    for(let i in left) {
        S.push(")")
    }

    console.log(S.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));