#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
const long long int mod = 1000000007;
long long int cost[1000005];
int res[1000005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &cost[i]);
  }
  priority_queue<pair<long long int, long long int> > qu;
  for (int i = 1; i <= k; i++) {
    qu.push(make_pair(cost[i], i));
  }
  for (int i = k + 1; i <= n; i++) {
    qu.push(make_pair(cost[i], i));
    pair<long long int, long long int> tem = qu.top();
    qu.pop();
    res[tem.second] = i;
  }
  int now = n + 1;
  while (!qu.empty()) {
    pair<long long int, long long int> tem = qu.top();
    qu.pop();
    res[tem.second] = now++;
  }
  long long int total = 0;
  for (int i = 1; i <= n; i++) total += (res[i] - i) * cost[i];
  printf("%lld\n", total);
  for (int i = 1; i <= n; i++) printf("%d ", res[i]);
  return 0;
}
