import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    string s = read!string;

    int lparen = 0;
    int h = 0;
    foreach (c; s) {
        if (c == '(') h++;
        else {
            h--;
            lparen = min(lparen, h);
        }
    }

    foreach (_; 0..-lparen) write('(');
    write(s);
    foreach (_; 0..h-lparen) write(')');
    writeln();
}
