#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 10;
int n, k, c[maxN], ans[maxN];
long long res;
struct cmp {
  bool operator()(int i, int j) { return c[j] > c[i]; }
};
priority_queue<int, vector<int>, cmp> heap;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  for (int i = 1; i <= k; ++i) heap.push(i);
  for (int i = k + 1; i <= k + n; ++i) {
    if (i <= n) heap.push(i);
    int u = heap.top();
    heap.pop();
    ans[u] = i;
    res += 1ll * c[u] * (i - u);
  }
  cout << res << endl;
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
}
