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] return N=int(input()) #saras=[1,2,3,4] saras=input() ss=saras.split(" ") saras=list(map(int,saras.split(" "))) val=[False]*N val[0]=1 val[1]=2 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) #print(val) #print(res) print(val[N-1]) hoge=list(map(lambda x:x+1,res[N-1])) print(" ".join(map(str,hoge)))