#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long>> in(n);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    in[i] = make_pair(x, i);
  }
  sort(in.rbegin(), in.rend());
  set<long long> ind;
  for (long long i = k; i < n + k; i++) {
    ind.insert(i);
  }
  long long price = 0;
  vector<long long> ans(n);
  for (auto plane : in) {
    auto it = ind.lower_bound(plane.second);
    if (it == ind.end()) {
      cout << -1 << endl;
      return 0;
    }
    price += (*it - plane.second) * plane.first;
    ans[plane.second] = *it;
    ind.erase(it);
  }
  cout << price << endl;
  for (long long i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
