public static void main ( String [ ] args ) {
  FastScanner sc = new FastScanner ( ) ;
  PrintWriter out = new PrintWriter ( System . out ) ;
  int n = sc . nextInt ( ) ;
  int k = sc . nextInt ( ) ;
  Node [ ] arr = new Node [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    arr [ i ] = new Node ( i , sc . nextInt ( ) ) ;
  }
  PriorityQueue < Node > q = new PriorityQueue < Node > ( ) ;
  long cur = 0 ;
  long sum = 0 ;
  for ( int i = 0 ;
  i < k ;
  i ++ ) {
    sum += cur ;
    cur += arr [ i ] . c ;
    q . add ( arr [ i ] ) ;
  }
  sum += cur ;
  int [ ] ans = new int [ n ] ;
  for ( int i = k ;
  i < n + k ;
  i ++ ) {
    if ( i < n ) {
      cur += arr [ i ] . c ;
      q . add ( arr [ i ] ) ;
    }
    Node temp = q . poll ( ) ;
    cur -= temp . c ;
    ans [ temp . i ] = i ;
    sum += cur ;
  }
  out . println ( sum ) ;
  for ( int e : ans ) out . print ( ( e + 1 ) + " " ) ;
  out . close ( ) ;
}

public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Node [ ] arr = new Node [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = new Node ( i , sc . nextInt ( ) ) ; } PriorityQueue < Node > q = new PriorityQueue < Node > ( ) ; long cur = 0 ; long sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += cur ; cur += arr [ i ] . c ; q . add ( arr [ i ] ) ; } sum += cur ; int [ ] ans = new int [ n ] ; for ( int i = k ; i < n + k ; i ++ ) { if ( i < n ) { cur += arr [ i ] . c ; q . add ( arr [ i ] ) ; } Node temp = q . poll ( ) ; cur -= temp . c ; ans [ temp . i ] = i ; sum += cur ; } out . println ( sum ) ; for ( int e : ans ) out . print ( ( e + 1 ) + " ▁ " ) ; out . close ( ) ; }
(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)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) 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: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (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))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (field_access object: (identifier) field: (identifier))) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (string_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))