#include <bits/stdc++.h>
using namespace std;
const int nMax = 300005;
pair<int, int> c[nMax];
int loc[2 * nMax];
int pleaca[2 * nMax];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> c[i].first, c[i].second = i;
  sort(c + 1, c + n + 1);
  set<int> pos;
  for (int i = k + 1; i <= n + k; ++i) pos.insert(i);
  for (int i = n; i >= 1; --i) {
    auto liber = pos.lower_bound(c[i].second);
    loc[*liber] = i;
    pleaca[c[i].second] = *liber;
    pos.erase(liber);
  }
  vector<int> rasp;
  long long ans = 0;
  for (int i = k + 1; i <= n + k; ++i)
    ans += 1LL * (i - c[loc[i]].second) * c[loc[i]].first;
  cout << ans << "\n";
  for (int i = 1; i <= n; ++i) cout << pleaca[i] << " ";
  return 0;
}
