import sys

n = int(sys.stdin.readline())

colo = list(map(int, input().split()))

# seredne = sum(colo) // 3

# answer = []
# for i in range(n):
#     a = colo[i]
#     next_number = i + 1
#     while a < seredne:
#         a += next_number
#         next_number += 1
#         if next_number > n - 1:
#             next_number = 0
#     if next_number == seredne:
#         answer.append(a)
#     if len(answer) == 3:
#         break



if n == 3:
    print(max(colo[0], colo[1], colo[2]) - min(colo[0], colo[1], colo[2]))
    answer = [colo[0], colo[1], colo[2]]
    result_numbers = ""
    for i in range(len(answer)):
        result_numbers += str(answer[i])
        if i < 2:
            result_numbers += " "
    print(result_numbers)