// yukicoder: No.258 回転寿司(2)
// 2019.8.21 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() { // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示(出力)
	int i; char b[30];
	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
}

int dp[1005], pre[1005];
int ans[1005]; int w = 1000;

void pr(int n) {
	while (n > 0) ans[--w] = n, n = pre[n];
	out(ans[w++]);
	while (ans[w]) pc(' '), out(ans[w++]);
	pc('\n');
}

int main()
{
	int i, j, v, vv, N;

	N = in();
	pre[1] = -1, dp[1] = vv = in();
	for (i = 2; i <= N; i++) {
		v = in();
		if (dp[i-1]-vv < dp[i-2]) pre[i] = i-2, dp[i] = dp[i-2]+v;
		else pre[i] = pre[i-1], dp[i] = dp[i-1]-vv+v;
		vv = v;
	}
	if (dp[N] > dp[N-1]) out(dp[N]), pc('\n'), pr(N);
	else out(dp[N-1]), pc('\n'), pr(N-1);
	return 0;
}