N = int(input()) V = list(map(int, input().split())) inf = 10 ** 18 dp0 = [-inf] * (N + 1) dp1 = [-inf] * (N + 1) dp0[0] = 0 for i in range(N): dp1[i + 1] = dp0[i] + V[i] dp0[i + 1] = max(dp0[i], dp1[i]) now = max(dp1) print(now) ans = [] for i in range(N, 0, -1): if now == dp1[i] and now == dp0[i - 1] + V[i - 1]: ans.append(i) now -= V[i - 1] print(*sorted(ans))