static void dfs ( long x , int len , long s ) {
  if ( x <= 7 ) {
    if ( res < len + x ) {
      res = len + x ;
      ans = s + x ;
    }
    else if ( res == len + x && ans < s + x ) ans = s + x ;
    return ;
  }
  int lb = 1 , ub = 100000 ;
  int ans = 1 ;
  while ( ub >= lb ) {
    int mid = ub + lb >> 1 ;
    if ( mul [ mid ] > x ) {
      ub = mid - 1 ;
    }
    else {
      lb = mid + 1 ;
      ans = mid ;
    }
  }
  dfs ( x - mul [ ans ] , len + 1 , s + mul [ ans ] ) ;
  dfs ( mul [ ans ] - mul [ ans - 1 ] - 1 , len + 1 , s + mul [ ans - 1 ] ) ;
}

static void dfs ( long x , int len , long s ) { if ( x <= 7 ) { if ( res < len + x ) { res = len + x ; ans = s + x ; } else if ( res == len + x && ans < s + x ) ans = s + x ; return ; } int lb = 1 , ub = 100000 ; int ans = 1 ; while ( ub >= lb ) { int mid = ub + lb >> 1 ; if ( mul [ mid ] > x ) { ub = mid - 1 ; } else { lb = mid + 1 ; ans = mid ; } } dfs ( x - mul [ ans ] , len + 1 , s + mul [ ans ] ) ; dfs ( mul [ ans ] - mul [ ans - 1 ] - 1 , len + 1 , s + mul [ ans - 1 ] ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))))) (return_statement))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))))