#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx = 1e5 + 5;
int n, k;
int dp[nx][205];
int choice[nx][205];
int a[nx];
ll solve(int idx, int rem) {
if (idx > n) return 0;
if (rem < 0) return 0;
if (dp[idx][rem] != -1) return dp[idx][rem];
if (rem == 0) {
choice[idx][rem] = n;
return dp[idx][rem] = 0;
}
int select = n;
ll mx = 0;
if (rem >= 1) {
for (int i = idx; i + 1 <= n; i++) {
ll val = solve(i + 1, rem - 1) + (a[n] - a[i]) * (a[i] - a[idx - 1]);
if (val > mx) mx = val, select = i;
}
}
dp[idx][rem] = mx;
choice[idx][rem] = select;
return mx;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
memset(dp, -1, sizeof dp);
dp[1][k] = solve(1, k);
/*for (int i = 0; i <= k; i++) {
for (int j = 1; j <= n; j++) {
cout << dp[j][i] << " ";
} cout << endl;
}*/
cout << dp[1][k] << "\n";
int i = choice[1][k--];
if (i != n) cout << i;
int ct = 0;
while (i != n) {
i++;
i = choice[i][k--];
if (i == n) break;
cout << " " << i;
}
}
/*
7 3
4 1 3 4 0 2 3
108
1 3 5
7 3
2 1 3 3 4 4 0
1 0
1
2 1
1 2
*/