#include "bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin >> n;
	string v;
	cin >> v;
	int counter = 0;
	string ans;
	for(char c:v){
		if(c == ')') counter--;
		else counter++;
		if(counter < 0) ans.insert(ans.begin(), '('), counter = 0;
		ans.push_back(c);
	}
	while(counter > 0) ans.push_back(')'), counter--;
	cout << ans << endl;
	return 0;
}
