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

void main()
{
  readln;
  int right;
  int left;
  auto s = readln.chomp;
  foreach(c; s) {
    if (c == '(') {
      ++right;
    } else {
      --right;
      if (right < 0) {
        ++left;
        right = 0;
      }
    }
  }
  writeln = '('.repeat.take(left).array ~ s ~ ')'.repeat.take(right).array;
}
