#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Swap(T &a, T &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
long long exp(long long a, unsigned long long b, unsigned long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
long long modInverse(long long a, unsigned long long m) {
  return exp(a, m - 2, m);
}
int main() {
  cout << boolalpha;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  vector<long long> c(n);
  for (int i = 0; i < n; ++i) cin >> c[i];
  ;
  set<long long> repo;
  for (int i = k + 1; i < n + k + 1; ++i) {
    repo.insert(i);
  }
  vector<pair<long long, long long> > C(n);
  for (int i = 0; i < n; ++i) {
    C[i].first = c[i];
    C[i].second = i + 1;
  }
  sort(C.rbegin(), C.rend());
  long long ans = 0;
  vector<int> sche(n);
  for (int i = 0; i < n; ++i) {
    auto lo = repo.lower_bound(C[i].second);
    if (lo != repo.end()) {
      ans = ans + (*lo - C[i].second) * C[i].first;
      sche[C[i].second - 1] = *lo;
      repo.erase(*lo);
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; ++i) {
    cout << sche[i] << " ";
  }
  cout << endl;
  return 0;
}
