#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n;
string second;
int get_ans(string second) {
  int ans = second.size();
  int bal = 0;
  for (int i = 0; i < second.size(); i++) {
    if (second[i] == '(') {
      bal++;
    } else {
      if (bal == 0)
        ans++;
      else
        bal--;
    }
  }
  ans += bal;
  return ans;
}
bool can(string &second, int ind, int bal, int add) {
  for (int i = 0; i < second.size(); i++) {
    if (second[i] == '(') {
      bal++;
    } else {
      if (bal == 0) {
        if (add == 0) return false;
        add--;
      } else
        bal--;
    }
  }
  if (add != bal) return false;
  return true;
}
int main() {
  cin >> n;
  cin >> second;
  int bal = 0;
  for (int i = 0; i < n; i++) {
    if (second[i] == '(')
      bal++;
    else
      bal--;
  }
  int len = get_ans(second);
  int add = len - n;
  string ans = "";
  bal = 0;
  for (int i = 0; i < n; i++) {
    if (add == 0) {
      ans += second[i];
      if (second[i] == '(')
        bal++;
      else
        bal--;
      continue;
    }
    if (second[i] == '(') {
      ans += second[i];
      bal++;
    } else {
      if (can(second, i + 1, bal + 1, add - 1)) {
        ans += '(';
        add--;
        bal++;
        i--;
        continue;
      } else {
        bal--;
        ans += ')';
      }
    }
  }
  while (add--) ans += ')';
  if (get_ans(ans) != ans.size()) assert(false);
  cout << ans << endl;
  return 0;
}
