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

int main() {
    {int n; cin >> n;}
    string s;
    cin >> s;
    int_fast64_t cur(0), mn(0);
    for(auto i : s){
        cur += (i ^ '(') ? -1 : 1;
        mn = min(cur, mn);
    }
    cur -= mn;
    for(; ++mn <= 0; fputc('(', stdout));
    cout << s;
    for(; --cur >= 0; fputc(')', stdout));
    cout << endl;
    return 0;
}