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

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	string s, ans;
	cin >> n >> s;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '(') ++cnt;
		else if (cnt == 0) ans = "(" + ans;
		else --cnt;
		ans.push_back(s[i]);
	}
	while (cnt--) {
		ans.push_back(')');
	}
	cout << ans << endl;
	return 0;
}