#include <bits/stdc++.h>
const int MAX = 300000 + 10;
using namespace std;
int n, k;
struct Node {
  long long c;
  long long id;
  long long order;
} node[MAX];
int vis[2 * MAX];
int cmp(Node x, Node y) { return x.c > y.c; }
int cmp1(Node x, Node y) { return x.id < y.id; }
int main() {
  while (~scanf("%d%d", &n, &k)) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) {
      node[i].id = i;
      scanf("%d", &node[i].c);
    }
    sort(node + 1, node + n + 1, cmp);
    long long ans = 0;
    int m = k + 1;
    for (int i = 1; i <= n; i++) {
      if (node[i].id >= k + 1 && node[i].id <= k + n && !vis[node[i].id]) {
        vis[node[i].id] = 1;
        node[i].order = node[i].id;
        while (vis[m]) m++;
        continue;
      }
      vis[m] = 1;
      node[i].order = m;
      while (vis[m]) m++;
    }
    sort(node + 1, node + n + 1, cmp1);
    for (int i = 1; i <= n; i++)
      ans += (node[i].c * (node[i].order - node[i].id));
    printf("%lld\n", ans);
    printf("%d", node[1].order);
    for (int i = 2; i <= n; i++) printf(" %d", node[i].order);
    printf("\n");
  }
}
