#include <bits/stdc++.h>
using namespace std;
const int BLACK = 1, WHITE = 2;
struct compare {
  bool operator()(const pair<long long int, long long int> &lhs,
                  const pair<long long int, long long int> &rhs) const {
    if (lhs.first != rhs.first) {
      return lhs.first > rhs.first;
    }
    return lhs.second > rhs.second;
  }
};
multiset<pair<long long int, long long int>, compare> myset;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  vector<long long int> a(n);
  for (auto &x : a) scanf("%lli", &x);
  for (int i = (0); i <= (min(k, n - 1)); i++) {
    myset.insert({a[i], i + 1});
  }
  long long int present = k + 1;
  int j = min(k, n - 1) + 1;
  pair<long long int, long long int> p;
  long long int ans = 0;
  map<long long int, long long int> mp;
  while (!myset.empty()) {
    p = *myset.begin();
    myset.erase(p);
    ans += (present - p.second) * p.first;
    mp[p.second - 1] = present;
    present++;
    if (j < n) {
      myset.insert({a[j], j + 1});
      j += 1;
    }
  }
  printf("%lli\n", ans);
  for (int i = (0); i <= (n - 1); i++) {
    printf("%lli ", mp[i]);
  }
  return 0;
}
