import std.algorithm,
       std.string,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int N = readln.chomp.to!int;
  string S = readln.chomp;

  char l = '(',
       r = ')';

  int ls,
      rs;
  int als;

  foreach (c; S) {
    if (c == l) { ls++; }
    else        { rs++; }

    if (ls - rs < 0) {
      als++;
      ls = 0;
      rs = 0;
    }
  }

  als.iota.each!(_ => write(l));
  write(S);
  (ls-rs).iota.each!(_ => write(r));
  writeln;
}
