N = int(input()) Vs = list(map(int, input().split())) def solve(N, Vs): a = [0] * (N + 1) b = [0] * (N + 1) a_used = [] b_used = [] for i, vi in enumerate(Vs, 1): a[i] = vi + b[i - 1] new_a_used = b_used[:] + [i] if a[i-1] > b[i-1]: b[i] = a[i - 1] b_used = a_used else: b[i] = b[i - 1] a_used = new_a_used if a[-1] > b[-1]: return a[-1], a_used else: return b[-1], b_used max_sumv, selected_vs = solve(N, Vs) print(max_sumv) print(*selected_vs)