#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long>> a(n);
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
    s.insert(i + k);
  }
  vector<long long> ans(n);
  sort(a.rbegin(), a.rend());
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    long long pos = a[i].second;
    auto it = s.lower_bound(pos);
    ans[a[i].second] = (*it) + 1;
    sum += (a[i].first) * (*it - a[i].second);
    s.erase(it);
  }
  cout << sum << endl;
  for (auto &i : ans) {
    cout << i << " ";
  }
  return 0;
}
