#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, i, a, b;
	int l = 0, r = 0; 
	string s;
	
	cin >> n;
	cin >> s;

	for (i = 0; i < n; i++){
		if (s[i] == '('){
			l += 1;
		} else if (s[i] == ')' &&  l > 0){
			l -= 1;
		} else {
			r += 1;;
		}
	}

	for (a = 0; a < l; a++){
		s = s + ')';
	}
	for (b = 0; b < r; b++){
		s = '(' + s;
	} 

	cout << s << endl;

}