#include <iostream>
using namespace std;
const int N = 1e3 + 1;
typedef long long ll;
typedef pair<ll, ll> pll;
ll t[N];
ll ans[N][N][201];
pll be[N][N][201];
ll sum[N];
const ll INF = 1e14;
int n;
ll calc(int a, int b, int k) {
if(k == 0) return 0;
if(ans[a][b][k] != 0) {
return ans[a][b][k] - 1;
}
ll an = -INF;
for(int i = a; i < b; ++i) {
ll cur = (sum[i] - sum[a-1])*(sum[b] - sum[i]);
cur += calc(i+1, b, k-1);
if(cur >= an) {
be[a][b][k] = {i, -1};
}
an = max(an, cur);
cur = (sum[i] - sum[a-1])*(sum[b] - sum[i]);
cur += calc(a, i, k-1);
if(cur >= an) {
be[a][b][k] = {i, 1};
}
an = max(an, cur);
}
ans[a][b][k] = an + 1;
return an;
}
int main() {
int k;
cin >> n >> k;
for(int i = 1; i <= n; ++i) {
cin >> t[i];
sum[i] = sum[i-1] + t[i];
}
cout << calc(1, n, k) << "\n";
int le = 1;
int ri = n;
while(k > 0) {
cout << be[le][ri][k].first << " ";
if(be[le][ri][k].second == 1) {
ri = be[le][ri][k].first;
} else {
le = be[le][ri][k].first;
}
--k;
}
cout << "\n";
}