#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first > b.first) return true;
  if (a.first == b.first) return a.second < b.second;
  return false;
}
int main() {
  int n, k;
  cin >> n >> k;
  pair<int, int> cost[n];
  for (int i = 0; i < n; i++) {
    cost[i].second = i + 1;
    cin >> cost[i].first;
  }
  vector<int> v(n);
  set<int> s;
  for (int i = k + 1; i <= k + n; i++) s.insert(i);
  sort(cost, cost + n, comp);
  long long ans = 0;
  int t;
  for (int i = 0; i < n; i++) {
    int c = cost[i].first;
    if (t <= k) t = k + 1;
    t = *(s.lower_bound(cost[i].second));
    s.erase(t);
    v[cost[i].second - 1] = t;
    ans += (t - cost[i].second) * 1LL * c;
  }
  cout << ans << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
}
