#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <cstdio>
//#include <sys/resource.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
void print(long long t) {cerr << t;}
void print(int t) {cerr << t;}
void print(string t) {cerr << t;}
void print(char t) {cerr << t;}
void print(double t) {cerr << t;}
void print(long double t) {cerr << t;}
void print(unsigned long long t) {cerr << t;}
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T> void print(deque <T> v);
template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(queue <T> q) {cerr << "[ "; while(!q.empty()) {print(q.front()); cerr << " "; q.pop();} cerr << "]";}
template <class T> void print(priority_queue <T> q) {cerr << "[ "; while(!q.empty()) {print(q.top()); cerr << " "; q.pop();} cerr << "]";}
template <class T> void print(deque <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(int n__, T arr[]) {cerr << "[ "; for(int i = 0; i <= n__; i++) {print(arr[i]); cerr << " ";} cerr << "]\n";}
#define pb push_back
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define noAnsw cout << -1 << '\n'
#define ll long long
#define ppb pop_back
#define OK cout << "OK" << endl;
#define ld long double
#define all(v) (v).begin(), (v).end()
#define MP make_pair
#define PII pair <int, int>
#define endl '\n'
#define ull unsigned long long
#define PLL pair <ll, ll>
#define PIL pair <int, ll>
#define PLI pair <ll, int>
#define rall(v) (v).rbegin(), (v).rend()
#define priora priority_queue
#define urishOK cout << "urishOK\n";
// void increaseStack(rlim_t stackSize) {
// struct rlimit rl;
// int result;
// result = getrlimit(RLIMIT_STACK, &rl);
// if (result == 0) {
// if (rl.rlim_cur < stackSize) {
// rl.rlim_cur = stackSize;
// result = setrlimit(RLIMIT_STACK, &rl);
// if (result != 0) {
// cerr << "Error setting stack size." << endl;
// }
// }
// }
// }
void setIO(string name = "") {
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void fastIO(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
void setPrecision(int x){
if(x == 0){
return;
}
cout.setf(ios::fixed);
cout.precision(x);
return;
}
const int inf = 1e9 + 5, LOG = 30;
const ll inf64 = 1e18 + 5, mod = 1e9 + 7, wmod = 998244353;
const double epsilon = 0.000001, pi = 3.14159265359;
const int N = 1e5 + 5, K = 205;
int n, k;
ll dp[N][2], a[N];
int opt[N][K];
ll cost(int i, int j) {return (a[i] - a[j]) * a[j];}
void DandC(int l, int r, int optl, int optr, int j){
int mid = (r + l) / 2, optmid = 0;
for(int i = optl; i <= min(optr, mid - 1); i++){
if(dp[i][0] + cost(mid, i) >= dp[mid][1]){
optmid = i;
dp[mid][1] = dp[i][0] + cost(mid, i);
}
}
opt[mid][j] = optmid;
if(l == r) return;
DandC(l, mid, optl, optmid, j);
DandC(mid + 1, r, optmid, optr, j);
}
void solve(int TST_NUM){
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
a[i] += a[i - 1];
}
for(int i = 1; i <= n; i++) dp[i][0] = 0;
for(int j = 2; j <= k + 1; j++){
DandC(1, n, 1, n - 1, j);
for(int i = 1; i <= n; i++){
dp[i][0] = dp[i][1];
dp[i][1] = 0;
}
}
for(int i = 2; i <= n; i++){
for(int j = 2; j <= k + 1; j++){
//if(!opt[i][j]) continue;
assert(opt[i][j] >= opt[i - 1][j]);
}
}
// for(int j = 2; j <= k + 1; j++){
// for(int i = 1; i <= n; i++){
// cout << opt[i][j] << ' ';
// }
// cout << endl;
// }
cout << dp[n][0] << endl;
int curr = n;
vector <int> answ;
for(int i = k + 1; i >= 2; i--){
answ.pb(opt[curr][i]);
curr = opt[curr][i];
if(answ.size() >= 2) assert(answ[answ.size() - 1] != answ[answ.size() - 2]);
}
reverse(all(answ));
for(int i : answ){
cout << i << ' ';
}
cout << endl;
}
int main(){
setPrecision(1);
fastIO();
//increaseStack(64 * 1024 * 1024);
//setIO("file");
int Tests = 1;
//cin >> Tests;
int TST_NUM = 1;
while(Tests--){
solve(TST_NUM++);
}
return 0;
}
//mcmcmcmcmcmcmcmcmcmcmc
//mcmcmcmcmcmcmcmcmcmcmc
//mcmcmcmcmcmcmcmcmcmcmc
//mcmcmcmcmcmcmcmcmcmcmc
//matsak