贪心、前缀和
// Problem: D - Insertion
// URL: https://atcoder.jp/contests/abc064/tasks/abc064_d
// Author: Pengfei Xu
#include <bits/stdc++.h>
using namespace std;
const int maxn=102;
int pre[maxn];
void solve(){
int n; string s; cin >> n >> s;
for(int i=1;i<=n;++i)
if(s[i-1]=='(') pre[i]=pre[i-1]-1;
else pre[i]=pre[i-1]+1;
int ls = *max_element(pre,pre+n+1);
int rs = ls-pre[n];
string t(ls,'(');
string u(rs,')');
cout << t+s+u << endl;
}
int main(){
int T=1;
while(T--) solve();
}