#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define REP(i, a, n) for(int i= a; i<n; i++)

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

	int l = 0, r = 0;
	REP(i, 0, N) {
		if (S[i] == '(') l++;
		else {
			if (l > 0) l--;
			else r++;
		}
	}
	REP(i, 0, l) S = S + ')';
	REP(i, 0, r) S = '(' + S;

	cout << S << endl;
	return 0;
}