#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > q;
long long result[300010];
int main() {
  long long n, k, i, planetime, sum = 0;
  cin >> n >> k;
  for (i = 1; i <= n + k; i++) {
    if (i <= n) {
      cin >> planetime;
      q.push({planetime, i});
    }
    if (i > k) {
      result[q.top().second] = i;
      sum += (q.top().first * (i - q.top().second));
      q.pop();
    }
  }
  cout << sum << endl;
  for (i = 1; i <= n; i++) cout << result[i] << " ";
}
