# your code goes here
n = []
index_ = []
result = 0
for _ in range(8):
    n.append(int(input()))
for _ in range(5):
    result += max(n)
    index_.append(n.index(max(n))+1)
    a = n.index(max(n))
    n[a] = 0
index_.sort()
print(result)
print(*index_)
