#include <bits/stdc++.h>
using namespace std;
const int N = 600005;
int n, k;
vector<int64_t> t(600005, 0), c(600005, 0);
int64_t rez;
priority_queue<pair<int, int>> p_que;
void createPQue() {
  int p_queDim;
  if (n > k + 1)
    p_queDim = k + 1;
  else
    p_queDim = n;
  pair<int, int> local;
  for (int i = 1; i <= p_queDim; i++) {
    local.first = c[i];
    local.second = i;
    p_que.push(local);
  }
}
void update_p_que(int next_poz) {
  pair<int, int> local;
  local.first = c[next_poz];
  local.second = next_poz;
  p_que.pop();
  p_que.push(local);
}
void showRez() {
  cout << 0 - rez << "\n";
  for (int i = 1; i <= n; i++) cout << t[i] << " ";
}
int main() {
  cin >> n >> k;
  int nextCost = k + 1;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    rez += c[i] * i;
  }
  createPQue();
  for (int64_t i = nextCost; i <= n + k; i++) {
    pair<int, int> local = p_que.top();
    t[local.second] = i;
    rez -= local.first * i;
    update_p_que(i + 1);
  }
  showRez();
  return 0;
}
