#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, k;     cin >> n >> k;     vector<pair<long long, int> > c(n);     vector<int> ans(n);     for (int i = 0; i < n; ++i) {       cin >> c[i].first;       c[i].second = i;     }     set<pair<long long, int> > av;     for (int i = 0; i < k; ++i) av.insert(c[i]);     int now = k;     long long cost = 0;     for (int i = 0; i < n; ++i) {       if (now < n) av.insert(c[now]);       ans[av.rbegin()->second] = ++now;       cost += av.rbegin()->first * (now - av.rbegin()->second - 1);       av.erase(*av.rbegin());     }     cout << cost <<   n ;     for (int i : ans) cout << i <<    ;     return 0;   }   