public static void main ( String [ ] $ ) {
  Scanner sc = new Scanner ( in ) ;
  int n = sc . nextInt ( ) ;
  int [ ] c = new int [ n + 1 ] ;
  String s = sc . next ( ) ;
  String r = "" ;
  String l = "" ;
  int neg = 101 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    char a = s . charAt ( i ) ;
    if ( a == '(' ) c [ i + 1 ] = c [ i ] + 1 ;
    else c [ i + 1 ] = c [ i ] - 1 ;
    neg = min ( c [ i + 1 ] , neg ) ;
  }
  for ( int i = 0 ;
  i < - neg ;
  i ++ ) {
    l += "(" ;
  }
  s = l + s ;
  int temp = 0 ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    if ( s . charAt ( i ) == '(' ) temp ++ ;
    else temp -- ;
  }
  for ( int i = 0 ;
  i < temp ;
  i ++ ) {
    r += ")" ;
  }
  out . println ( s + r ) ;
}

public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int [ ] c = new int [ n + 1 ] ; String s = sc . next ( ) ; String r = " " ; String l = " " ; int neg = 101 ; for ( int i = 0 ; i < n ; i ++ ) { char a = s . charAt ( i ) ; if ( a == ' ( ' ) c [ i + 1 ] = c [ i ] + 1 ; else c [ i + 1 ] = c [ i ] - 1 ; neg = min ( c [ i + 1 ] , neg ) ; } for ( int i = 0 ; i < - neg ; i ++ ) { l += " ( " ; } s = l + s ; int temp = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' ( ' ) temp ++ ; else temp -- ; } for ( int i = 0 ; i < temp ; i ++ ) { r += " ) " ; } out . println ( s + r ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) alternative: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (unary_expression operand: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (update_expression (identifier))) alternative: (expression_statement (update_expression (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (string_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))))