#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input()\n"
"s=input()\n"
"while 1:\n"
"  for i in range(len(s)):\n"
"    if s[i]=='('and s[i:].count(')')<(len(s)-i)/2:\n"
"      s+=')'\n"
"      break\n"
"  else:\n"
"    break\n"
"print('('*(s.count(')')-s.count('('))+s)\n"
"\"";
  system(s);
  return 0;
}            