#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v, vcopy;
  vector<long long> finalPlace(n + 1, -1);
  set<long long> s;
  for (long i = 0; i < n; i++) {
    long long cost;
    cin >> cost;
    v.push_back(make_pair(cost, i + 1));
    s.insert(k + 1 + i);
  }
  vcopy = v;
  sort(v.begin(), v.end());
  for (long long i = n - 1; i >= 0; i--) {
    set<long long>::iterator pos = s.lower_bound(v[i].second);
    finalPlace[v[i].second] = *pos;
    s.erase(pos);
  }
  long long minCost = 0;
  for (long long i = 1; i <= n; i++) {
    minCost += vcopy[i - 1].first * (finalPlace[i] - vcopy[i - 1].second);
  }
  cout << minCost << endl;
  for (long long i = 1; i <= n; i++) {
    cout << finalPlace[i] << " ";
  }
  cout << endl;
  return 0;
}
