import sys N=input() V=map(int,raw_input().split()) dp=[0 for _ in range(N)] r=[[] for _ in range(N)] if N == 1: print V[0] print 1 sys.exit() dp[0]=V[0] r[0]=[1] if V[0] < V[1]: dp[1] = V[1] r[1] = [2] else: dp[1] = V[0] r[1] = [1] for i in range(2,N): for j in range(0,i-1): if dp[j]+V[i] > dp[i]: dp[i]=dp[j]+V[i] r[i]=list(r[j]) r[i].append(i+1) if dp[i] < dp[i-1]: dp[i]=dp[i-1] r[i]=r[j] print dp[N-1] print ' '.join(map(str,r[N-1])).rstrip(' ')