#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, k, a[maxn], indx[maxn], ans[maxn];
long long sum;
set<int> s;
bool cmp(int u, int v) { return a[u] > a[v]; }
int main() {
  cin >> n >> k;
  iota(indx, indx + maxn, 0);
  for (int i = k; i < n + k; i++) s.insert(i);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(indx, indx + n, cmp);
  for (int i = 0; i < n; i++) {
    int j = indx[i];
    auto x = s.lower_bound(max(k, j));
    sum += (long long)a[j] * (*x - j);
    ans[j] = *x;
    s.erase(x);
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) cout << ans[i] + 1 << ' ';
  return 0;
}
