#include <bits/stdc++.h>
using namespace std;
struct Plane {
  long long c;
  long long i;
  bool operator<(const Plane& other) const {
    return c == other.c ? i < other.i : c < other.c;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  Plane c[n + k];
  for (int i = 0; i < n; i++) {
    cin >> c[i].c;
    c[i].i = i;
  }
  priority_queue<Plane> q;
  for (int i = 0; i < k; i++) {
    q.push(c[i]);
  }
  for (int i = k; i < n + k; i++) {
    if (i < n && q.top().c > c[i].c) {
      Plane top = q.top();
      q.pop();
      q.push(c[i]);
      c[i] = top;
    } else if (i >= n) {
      c[i] = q.top();
      q.pop();
    }
  }
  long long cost = 0;
  int ci[n];
  for (int i = k; i < n + k; i++) {
    cost += (i - c[i].i) * c[i].c;
    ci[c[i].i] = i + 1;
  }
  cout << cost << endl;
  for (int i = 0; i < n; i++) {
    cout << ci[i] << " ";
  }
}
