#include <bits/stdc++.h>
using namespace std;
struct REMOVE_DEBUG_OUTPUT {};
REMOVE_DEBUG_OUTPUT CERR_SHALL_NOT_PASS;
template <typename type>
REMOVE_DEBUG_OUTPUT& operator<<(REMOVE_DEBUG_OUTPUT& out, const type&) {
  return out;
}
template <typename type>
istream& operator>>(istream& in, vector<type>& a) {
  for (auto& x : a) {
    in >> x;
  }
  return in;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int64_t n, k;
  cin >> n >> k;
  vector<pair<int64_t, int64_t> > c(n);
  for (int64_t i = 0; i < n; ++i) {
    cin >> c[i].first;
    c[i].second = i;
  }
  vector<pair<int64_t, int64_t> > c1(c.begin(), c.end());
  sort(c1.begin(), c1.end());
  vector<int64_t> ans(n);
  int64_t ind = n - 1;
  int64_t ind1 = 0;
  int64_t max_time = n + k;
  while (ind >= 0 && ind1 < n) {
    if (ans[ind] == 0 && ind + 1 == max_time) {
      ans[ind--] = max_time--;
    } else {
      ans[c1[ind1++].second] = max_time--;
    }
    while (ind >= 0 && ans[ind] != 0) {
      --ind;
    }
    while (ind1 < n && ans[c1[ind1].second] != 0) {
      ++ind1;
    }
  }
  int64_t answer = 0;
  for (int64_t i = 0; i < n; ++i) {
    answer += (ans[i] - (i + 1)) * c[i].first;
  }
  cout << answer << "\n";
  for (auto& x : ans) {
    cout << x << " ";
  }
  cout << "\n";
  return 0;
}
