#include "bits/stdc++.h"
using namespace std;


int main() {
    int n;
    string s;
    cin >> n >> s;

    int cur = 0, pre = 0;
    for (auto&& c : s) {
        if (c == '(') cur++;
        else cur--;

        if (cur < 0) {
            pre++;
            cur++;
        }
    }

    cout << string(pre, '(') << s << string(cur, ')') << endl;

    return 0;
}