def f(n): global N,saras,val if n-1 in res[n-1]: a=val[n-2]+saras[n] b=val[n-1] if a<=b: res[n]=res[n-1][:] val[n]=val[n-1] else: res[n]=res[n-2][:] res[n].append(n) val[n]=val[n-2]+saras[n] else: res[n]=res[n-2][:] res[n].append(n) val[n]=val[n-2]+saras[n] return N=int(input()) #saras=[1,2,3,4] saras=input() ss=saras.split(" ") saras=list(map(int,saras.split(" "))) if N==1: print(1) print(saras[0]) exit() val=[False]*N val[0]=saras[0] val[1]=max(saras[0],saras[1]) res=[[]for i in range(N)] res[0]=[0] res[1]=[saras[0:2].index(max(saras[0],saras[1]))] for n in range(2,N): f(n) hoge=list(map(lambda x:x+1,res[N-1])) print(val[N-1]) print(" ".join(map(str,hoge)))