#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j;
  scanf("%lld %lld", &n, &k);
  pair<long long, long long> arr[n + 1];
  for (i = 1; i <= n; i++) {
    long long a;
    scanf("%lld", &a);
    arr[i] = {a, i};
  }
  sort(arr + 1, arr + n + 1);
  set<long long> second;
  for (i = k + 1; i <= n + k; i++) {
    second.insert(i);
  }
  long long ans[n + 1], cnt = 0;
  for (i = n; i > 0; i--) {
    long long curr = *(second.lower_bound(arr[i].second));
    second.erase(curr);
    ans[arr[i].second] = curr;
    cnt += (curr - arr[i].second) * arr[i].first;
  }
  printf("%lld\n", cnt);
  for (i = 1; i <= n; i++) {
    printf("%lld ", ans[i]);
  }
  printf("\n");
  return 0;
}
