import sys,heapq input = sys.stdin.buffer.readline n=int(input()) V=[int(i) for i in input().split()] DP=[[0]*2 for i in range(n+1)] for i,v in enumerate(V): DP[i+1][0]=max(DP[i]) DP[i+1][1]=DP[i][0]+v Ans=[] print(max(DP[n])) if DP[n][0]>=DP[n][1]: sig=0 else: sig=1 for i in range(n)[::-1]: if sig==1: Ans.append(i+1) sig=0 else: if DP[i][1]>DP[i][0]: sig=1 Ans=Ans[::-1] print(*Ans)