#include <bits/stdc++.h>
using namespace std;
long long n, k, re, sum;
int pr[300005], ti[300005];
priority_queue<pair<int, int> > pq;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> pr[i];
  for (int i = 1; i <= n + k; i++) {
    if (i <= n) {
      pq.push(make_pair(pr[i], i));
      sum += pr[i];
    }
    if (i > k) {
      ti[pq.top().second] = i;
      sum -= pq.top().first;
      pq.pop();
    }
    re += sum;
  }
  cout << re << endl;
  for (int i = 1; i <= n; i++) cout << ti[i] << " ";
  return 0;
}
