#include <bits/stdc++.h>
using namespace std;
long long n, k, c[3000001], s;
set<pair<long long, long long> > d, t;
set<pair<long long, long long> >::iterator p;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= k; i++) d.insert({c[i], i});
  for (int i = k + 1; i <= k + n; i++) {
    if (i <= n) d.insert({c[i], i});
    p = d.end();
    p--;
    long long r = (*p).first;
    long long l = (*p).second;
    s += ((i - l) * r);
    d.erase(p);
    t.insert({l, i});
  }
  cout << s << endl;
  for (auto e : t) cout << e.second << " ";
  return 0;
}
