#include <bits/stdc++.h>
using namespace std;
int M = 1e9 + 7;
bool dot(vector<int>& v1, vector<int>& v2) {
  int ans = 0;
  for (int i2 = 0; i2 < 5; i2++) {
    ans += v1[i2] * v2[i2];
  }
  return (ans > 0);
}
int main() {
  ios::sync_with_stdio(false);
  int i, n, k, free;
  long long cost = 0LL;
  scanf("%d%d", &n, &k);
  free = k + 1;
  vector<int> c(n), t(n, -1), f(n + k + 1, 0);
  vector<pair<int, int> > v(n);
  for (i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    v[i] = {c[i], i};
  }
  sort(v.begin(), v.end());
  for (i = n - 1; i >= 0; --i) {
    if (free < v[i].second + 1) {
      t[v[i].second] = v[i].second + 1;
      f[v[i].second + 1] = 1;
    } else {
      t[v[i].second] = free;
      f[free] = 1;
      for (++free; free <= k + n; free++) {
        if (f[free] == 0) {
          break;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    cost += (1LL * t[i] - (i + 1)) * 1LL * c[i];
  }
  cout << cost << endl;
  for (i = 0; i < n; i++) {
    cout << t[i] << ' ';
  }
  return 0;
}
