#include <bits/stdc++.h>
using namespace std;
struct flight {
  long long time, cost, nt;
  bool operator<(const flight& other) const { return (cost < other.cost); }
};
priority_queue<flight> q;
vector<flight> v;
bool cmp(flight a, flight b) { return a.time < b.time; };
int main() {
  int n, k;
  long long del = 0;
  cin >> n >> k;
  for (int i = 1; i <= n + k; i++) {
    if (i <= n) {
      flight f;
      cin >> f.cost;
      f.time = i;
      q.push(f);
    }
    if (i > k) {
      flight t = q.top();
      q.pop();
      t.nt = i;
      del += t.cost * (t.nt - t.time);
      v.push_back(t);
    }
  }
  sort(v.begin(), v.end(), cmp);
  cout << del << endl;
  for (int i = 0; i < n; i++) cout << v[i].nt << " ";
  return 0;
}
