// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector>

#include<stack>

#include <cmath>

#include <limits>

#include<set>

#include <iomanip>

#include <queue>

#include <map>

#include <string>

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;

const long long INF=(1LL<<62);

const double inf=pow(10,10);

double pi=3.141592653589793;

const int dx[4]={1,0,-1,0};

const int dy[4]={0,1,0,-1};

const ll MOD = 1000000007;

void init(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

}

ll N,A,B;

vector<ll>h(100005);

bool isOK(ll mid){

	ll ret=0;

	for(int i=0;i<N;i++){

		if(h[i]-mid*B>0){

			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);

		}

	}

	return ret<=mid;

}





int main(){

	init();

	ll N;cin>>N;

	string s;cin>>s;

	ll left=0;

	ll right=0;

	string ans;

	for(int i=0;i<N;i++){

		if(s[i]=='(')left++;

		if(s[i]==')')right++;

		if(right>left){

			right=left;

			ans.push_back('(');

		}

	}

	ans+=s;

	right=0;

	left=0;

	for(int i=0;i<ans.size();i++){

		if(ans[i]=='(')left++;

		if(ans[i]==')')right++;

	}

	//cout<<left-right<<endl;

	for(int i=0;i<left-right;i++)ans.push_back(')');

	cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
#include <cassert>

#include <cctype>

#include <cerrno>

#include <cfloat>

#include <ciso646>

#include <climits>

#include <clocale>

#include <cmath>

#include <csetjmp>

#include <csignal>

#include <cstdarg>

#include <cstddef>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <cwchar>

#include <cwctype>

#include <ccomplex>

#include <cfenv>

#include <cinttypes>

#include <cstdbool>

#include <cstdint>

#include <ctgmath>

#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>

#include <array>

#include <atomic>

#include <chrono>

#include <codecvt>

#include <condition_variable>

#include <forward_list>

#include <future>

#include <initializer_list>

#include <mutex>

#include <random>

#include <ratio>

#include <regex>

#include <scoped_allocator>

#include <system_error>

#include <thread>

#include <tuple>

#include <typeindex>

#include <type_traits>

#include <unordered_map>

#include <unordered_set>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define all(x) (x).begin(),(x).end()

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long int ll;

typedef long double ld;

const ll INF=(1LL<<62);

const ld pi=acosl((ld)-1);

// const ll mod = 1000000007;

const ll mod = 1234567;

const int dx[4]={0,1,0,-1};

const int dy[4]={1,0,-1,0};

const int ddx[8]={1,0,-1,-1,-1,0,1,1};

const int ddy[8]={1,1,1,0,-1,-1,-1,0};

#define endn "\n"



bool solve(){

    ll n;cin>>n;

    string s;cin>>s;

    {ll cnt=0;

    rep(i,n){

        if(s[i]=='(')cnt++;

        else cnt=max<ll>(0,cnt-1);   

    }

    rep(i,cnt)s.push_back(')');}

    // cout<<s<<endl;

    reverse(all(s));

    {ll cnt=0;

    rep(i,s.size()){

        if(s[i]==')')cnt++;

        else cnt=max<ll>(0,cnt-1);   

    }

    reverse(all(s));

    rep(i,cnt)s.insert(0,"(");

    }

    cout<<s<<endl;

    return false;

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout<<fixed<<setprecision(30);

    solve();

}


// Fastest known solution for this problem: