#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long x;
  vector<int> a(n);
  long long ans = 0;
  priority_queue<pair<long long, long long> > pq;
  for (int i = 1; i <= (n + k); i++) {
    if (i <= n) {
      cin >> x;
      pq.push({x, i});
    }
    if (i > k) {
      pair<long long, long long> t = pq.top();
      pq.pop();
      ans += t.first * (i - t.second);
      a[--t.second] = i;
    }
  }
  cout << ans << "\n";
  for (auto it : a) {
    cout << it << ' ';
  }
  cout << "\n";
}
