n=gets.to_i v=gets.split.map &:to_i d=[0] e=[[]] 0.upto(n-1){|i|u=(d[i-1]||0)+v[i];d[i+1],e[i+1]=u>d[i]?[u,e[i-1]+[i+1]]:[d[i],e[i]]} p d[n] puts e[n]*' '