#include <iostream>
#include <string>
using namespace std;
int main() {
    int N, cnt = 0;
    string S, ans;
    cin >> N >> S;
    ans = S;
    for (int i = 0; i < N; i++) {
        if (S[i] == '(') cnt++;
        if (S[i] == ')') {
            if (cnt == 0) ans = '(' + ans;
            else cnt--;
        }
    }
    for (int i = 0; i < cnt; i++) ans += ')';
    cout << ans << endl;
}