#include <bits/stdc++.h>
using namespace std;
int n, k, s[600055], p[600055];
bool done[600055];
long long c[600055];
vector<pair<long long, long long> > a;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lld", c + i);
  for (int i = 1; i <= n; i++) s[i] = i;
  for (int i = 1; i <= n; i++)
    a.push_back((pair<long long, long long>){c[i], i});
  sort(a.begin(), a.end());
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (s[n + k - i] != 0)
      done[s[n + k - i]] = 1;
    else {
      while (done[a[j].second]) j++;
      s[n + k - i] = a[j].second;
      s[a[j].second] = 0;
      done[a[j].second] = 1;
    }
  }
  long long cost = 0;
  for (int i = k + 1; i <= k + n; i++) cost += (long long)(i - s[i]) * c[s[i]];
  printf("%lld\n", cost);
  for (int i = k + 1; i <= k + n; i++) p[s[i]] = i;
  for (int i = 1; i <= n; i++) printf("%d%c", p[i], (i == n) ? '\n' : ' ');
  return 0;
}
