def minimum_pollen(f: list, n):
c = [0] * len(f)
c[0], c[1] = f[0], f[1]
way = [[0]] * len(f)
way[0], way[1] = [0], [1]
for i in range(2, len(f)):
c[i] = min(c[i - 1], c[i - 2]) + f[i]
way[i] = way[c.index((min(c[i - 1], c[i - 2])), i - 2)] + [i]
return c[n - 1], way[n - 1]
n = int(input())
f = list(map(int, input().split()))
tmp1, tmp2 = minimum_pollen(f, n)
print(tmp1)
print(*tmp2)