#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<pair<int, int>> Cost;
  set<int> Time;
  for (int i = k + 1; i <= k + n; i++) Time.insert(i);
  vector<int> Ret(n, 0);
  int TCost;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &TCost);
    Cost.push_back(make_pair(TCost, i));
  }
  sort(Cost.begin(), Cost.end());
  long long TTime = 0;
  for (int i = Cost.size() - 1; i >= 0; i--) {
    auto Top = Cost[i];
    auto CTime = *(Time.lower_bound(Top.second));
    Time.erase(CTime);
    TTime += 1LL * (CTime - Top.second) * Top.first;
    Ret[Top.second - 1] = CTime;
  }
  printf("%lld\n", TTime);
  for (auto& Each : Ret) printf("%d ", Each);
  printf("\n");
  return 0;
}
