#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define pfd(n) printf("%d", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")

#define PI 3.1415926 

using namespace std;

int main() {
	int n;
	string str;
	cin >> n;
	getchar();
	cin >> str;
	string str1 = "(", str2 = ")", s = str;
	int l = 0, r = 0;
	int sl[n], sr[n];
	for( int i=0; i<n; i++ ) {
		if( str[i]=='(' ){
			l++;
		}
		sl[i] = l;
	}
	for( int i=n-1; i>=0; i-- ) {
		if( str[i]==')' ) {
			r++;
		}
		sr[i] = r;
	}
	for( int i=0; i<n; i++ ) {
		if( str[i]=='(' ) {
			if( sr[i]<sl[i] ) {
				s = s + str2;
			}
		}else if( str[i]==')' ) {
			if( sl[i]<sr[i] ) {
				s = str1 + s;
			}
		}
	}
	cout << s;
	pfn;
	return 0;
}