#include <bits/stdc++.h>
void quicksort(long long *a, long long *index, long long left,
               long long right) {
  long long temp;
  long long i = left;
  long long j = right;
  long long min = (left + right) / 2;
  long long pivot = a[min];
  while (left < j || i < right) {
    while (a[i] > pivot) i++;
    while (a[j] < pivot) j--;
    if (i <= j) {
      temp = a[i];
      a[i] = a[j];
      a[j] = temp;
      temp = index[i];
      index[i] = index[j];
      index[j] = temp;
      i++;
      j--;
    } else {
      if (left < j) quicksort(a, index, left, j);
      if (i < right) quicksort(a, index, i, right);
      return;
    }
  }
}
int main() {
  long long n, k, i, x;
  long long s = 0;
  scanf("%lld %lld", &n, &k);
  bool used[n + k];
  for (i = k; i <= n + k; i++) used[i] = false;
  long long a[n], index[n];
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    index[i] = i + 1;
  }
  long long phutbay[n + 1], incre = k + 1;
  quicksort(a, index, 0, n - 1);
  for (i = 0; i < n; i++) {
    x = index[i];
    if (x < incre) {
      while (used[incre] == true) incre++;
      x = incre;
      incre++;
    }
    used[x] = true;
    phutbay[index[i]] = x;
    s += (x - index[i]) * a[i];
  }
  printf("%lld\n", s);
  for (i = 1; i <= n; i++) printf("%lld ", phutbay[i]);
}
