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

int main(){
	int n;
	string s;
	cin >> n >> s;

	string ans = s;
	int cl = 0, cr = 0;
	for (int i = 0;i < n;i++) {
		if (s[i] == '(') {
			cl++;
		}
		else {
			cr++;
		}
		if (cl < cr) {
			ans = "(" + ans;
			cl++;
		}
	}
	if (cl > cr) {
		ans += string(cl - cr, ')');
	}
	cout << ans << endl;

	return 0;
}