N = int(raw_input()) data = map(int, raw_input().split()) if N == 1: print data[0] print 1 exit() dp = [0] * N dp[0] = data[0] dp[1] = max(dp[0], data[1]) for i in xrange(2, N): dp[i] = max(dp[i - 2] + data[i], dp[i - 1]) print dp[-1]+1 choice = [] for k in xrange(N - 1, 1, -1): if dp[k] - dp[k - 1] == 0: pass elif dp[k] - dp[k - 2] == data[k]: choice.append(k + 1) dp[k - 1] = 0 if dp[1] == data[1]: choice.append(2) elif dp[0] == data[0]: choice.append(1) choice.reverse() print " ".join(map(str, choice))