import sys

n = int(sys.stdin.readline())
nums = list(map(int, sys.stdin.readline().split()))

res = 100000

for x in range(0, len(nums)-2):
    for y in range(x+1, len(nums)-1):
        for z in range(y+1, len(nums)):
            sum_x, sum_y, sum_z = sum(nums[x:y]),sum(nums[y:z]),sum(nums[z:len(nums)])+sum(nums[0:x])
            if res > max(sum_x, sum_y, sum_z) - min(sum_x, sum_y, sum_z):
                res = max(sum_x, sum_y, sum_z) - min(sum_x, sum_y, sum_z)
                min_x, min_y, min_z = x+1, y+1, z+1

print(res)
print(min_x, min_y, min_z)