#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int at = 0, mini = 0;
    for (char c : S) {
        if (c == '(')
            at++;
        else
            at--;
        mini = min(mini, at);
    }

    cout << string(-mini, '(') + S + string(at - mini, ')') << endl;
}