private static void solveTestCase ( int testCaseID ) {
  int P = in . nextInt ( ) ;
  int K = in . nextInt ( ) ;
  int L = in . nextInt ( ) ;
  int [ ] freq = new int [ L ] ;
  for ( int i = 0 ;
  i < L ;
  ++ i ) {
    freq [ i ] = in . nextInt ( ) ;
  }
  Arrays . sort ( freq ) ;
  reverse ( freq ) ;
  int [ ] keys = new int [ K ] ;
  int curKey = - 1 ;
  long result = 0 ;
  for ( int i = 0 ;
  i < L ;
  ++ i ) {
    curKey = ( curKey + 1 ) % K ;
    keys [ curKey ] += 1 ;
    result += keys [ curKey ] * freq [ i ] ;
  }
  out . println ( String . format ( "Case #%d: %d" , testCaseID , result ) ) ;
}

private static void solveTestCase ( int testCaseID ) { int P = in . nextInt ( ) ; int K = in . nextInt ( ) ; int L = in . nextInt ( ) ; int [ ] freq = new int [ L ] ; for ( int i = 0 ; i < L ; ++ i ) { freq [ i ] = in . nextInt ( ) ; } Arrays . sort ( freq ) ; reverse ( freq ) ; int [ ] keys = new int [ K ] ; int curKey = - 1 ; long result = 0 ; for ( int i = 0 ; i < L ; ++ i ) { curKey = ( curKey + 1 ) % K ; keys [ curKey ] += 1 ; result += keys [ curKey ] * freq [ i ] ; } out . println ( String . format ( " Case ▁ # % d : ▁ % d " , testCaseID , result ) ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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 (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: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier)))) (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 (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_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 (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier))))))))