#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > Q;
const int maxn = 300000 + 10;
int a[maxn];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long ans = 0;
  for (int i = 1; i < n + k + 1; i++) {
    int t;
    if (i <= n) {
      scanf("%d", &t);
      Q.emplace(t, i);
    }
    if (i > k) {
      pair<int, int> x = Q.top();
      Q.pop();
      ans += (long long)(i - x.second) * x.first;
      a[x.second] = i;
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i < n + 1; i++) printf("%d ", a[i]);
  printf("\n");
  return 0;
}
