There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
n = int(input())
data = list(map(int, input().split()))
sum = 0
maximam = max(data)
ans = []
del data[data.index(max(data))]
for i in range(n - 2):
    ans.append([max(data) ,min(data)])
    data.append(min(data) - max(data))
    del data[data.index(max(data))]
    del data[data.index(min(data))]
print(maximam - data[0])
for i in ans:
    print("{} {}".format(i[0], i[1]))
print("{} {}".format(maximam, data[0]))
n = int(input())
data = list(map(int, input().split()))
data.sort()

if data[0] > 0:
    print(sum(data) - data[0] * 2)
    k = data[0]
    for i in range(1,n - 1):
        print("{} {}".format(k, data[i]))
        k -= data[i]
    print("{} {}".format(data[-1], k))

elif data[-1] <= 0:
    print(-sum(data) + (data[-1] * 2))
    k = data[-1]
    for i in range(n - 1):
        print("{} {}".format(k, data[i]))
        k -= data[i]

else: 
    print(sum(list(map(lambda x:abs(x), data))))
    max_data = data[-1]
    min_data = data[0]
    i = 1
    while data[i] <= 0:
        print("{} {}".format(max_data,data[i]))
        max_data -= data[i]
        i += 1
    while i < n - 1:
        print("{} {}".format(min_data, data[i]))
        min_data -= data[i]
        i += 1
    print("{} {}".format(max_data, min_data))


    


