#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
long n,c;
string s,head,tail;
int main(){
  cin>>n>>s;
  rep(i,n){
    c+=s[i]=='('?1:-1;
    if(c<0){
      head+="(";
      c++;
    }
  }
  while(c){
    tail+=")";
    c--;
  }
  cout<<head<<s<<tail<<endl;
}
