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

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

	string L = "(", R = ")";

	int depth = 0;
	string ans;
	for(char s:S){
		if(s == '('){
			depth++;
			ans += L;
		}
		else{
			depth--;
			ans += R;
			if(depth < 0){
				ans = L + ans;
				depth++;
			}
		}
	}

	while(depth--) ans += R;
	cout<< ans <<endl;
}