#include <bits/stdc++.h>
using namespace std;
int const N = 305;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > ans;
  multiset<pair<int, int> > ms;
  long long cost = 0;
  for (int i = 1; i <= (n + k); i++) {
    int c;
    if (i <= n) {
      cin >> c;
      ms.insert(make_pair(c, i));
    }
    if (i > k) {
      pair<int, int> aux = *ms.rbegin();
      ms.erase(ms.find(aux));
      cost += (long long)(i - aux.second) * aux.first;
      ans.push_back(make_pair(aux.second, i));
    }
  }
  sort(ans.begin(), ans.end());
  cout << cost << "\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i].second << " ";
  }
  cout << "\n";
  return 0;
}
