n = int(input())
nums = [int(i) for i in input().split()]
res = [10**16, -1, -1, -1]
only_ones = nums[0] in [0, 1]
 
prefix = [nums[0]]
for ind in range(1, n, 1):
    prefix.append(prefix[-1] + nums[ind])
    only_ones = only_ones and (nums[ind] in [0, 1])

if not only_ones:
    for ind1 in range(0, n - 1, 1):
        for ind2 in range(ind1 + 1, n, 1):
            for ind3 in range(ind2, n, 1):
                first_full = prefix[ind2 - 1] - (prefix[ind1 - 1] if ind1 != 0 else 0)
                second_full = prefix[ind3] - prefix[ind2 - 1]
                middle = (prefix[ind1 - 1] if ind1 != 0 else 0) + (prefix[n - 1] - prefix[ind3])
                new = max(first_full, second_full, middle) - min(first_full, second_full, middle)
                if new < res[0]:
                    res[0] = new
                    res[1], res[2], res[3] = ind1 + 1, ind2 + 1, ind3 + 2
else:
    sm = prefix[-1]
    need = sm // 3 + (sm % 3 == 2)
    ind = 1
    cur = 0
    res[1] = 1
    while res[3] == -1:
        cur += nums[ind]
        if cur == need:
            if res[2] == -1:
                res[2] = ind + 1
            elif res[3] == -1:
                res[3] = ind + 1
            cur = 0
        ind += 1

    res[0] = int(sm % 3 != 0)
 

print(res[0])
print(*res[1:])