static int solve ( int [ ] f , int k ) {
  int [ ] sorted = Arrays . stream ( f ) . boxed ( ) . sorted ( ) . mapToInt ( x -> x ) . toArray ( ) ;
  int result = 0 ;
  for ( int i = f . length - 1 ;
  i >= 0 ;
  i -= k ) {
    result += ( sorted [ i ] - 1 ) * 2 ;
  }
  return result ;
}

static int solve ( int [ ] f , int k ) { int [ ] sorted = Arrays . stream ( f ) . boxed ( ) . sorted ( ) . mapToInt ( x -> x ) . toArray ( ) ; int result = 0 ; for ( int i = f . length - 1 ; i >= 0 ; i -= k ) { result += ( sorted [ i ] - 1 ) * 2 ; } return result ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (identifier)))) name: (identifier) arguments: (argument_list)))) (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: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (assignment_expression left: (identifier) right: (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal)))))) (return_statement (identifier))))