#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string beginning, ending;
    int balance = 0;
    for (int i = 0; i < (int)(n); ++i) {
      if (s[i] == '(') {
        balance++;
      } else {
        balance--;
      }
      if (balance < 0) {
        beginning += '(';
        balance++;
      }
    }
    for (int i = 0; i < (int)(balance); ++i) {
      ending += ')';
    }
    cout << beginning + s + ending;
  }
}
