l = input().split()
n = int(l[0])

l = input().split()
A = [int(x) for x in l]

# print(N, A)

A.sort()
P = []
N = []
for a in A:
    if a >= 0:
        P.append(a)
    else:
        N.append(a)

def print_ans(ans, pairs):
    print(ans)
    for p in pairs:
        print(p[0], p[1])

def solve_p(A):
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((A[n - 1], ans))
    ans = A[n - 1] - ans
    print_ans(ans, pairs)

def solve_n(A):
    A.sort(key=lambda x: -x)
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((ans, A[n - 1]))
    ans -= A[-1]
    print_ans(ans, pairs)

# #P == 1
def solve1(P, N):
    ans = P[0]
    pairs = []
    for n in N:
        pairs.append((ans, n))
        ans -= n
    print_ans(ans, pairs)

# #N == 1 #P > 1
def solve2(P, N):
    ans = N[0]
    pairs = []
    for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

# #P > #N
def solve3(P, N):
    num_p = len(P)
    num_n = len(N)
    ans = P[0]
    pairs = []
    for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
    pairs.append((N[-1], ans))
    ans = N[-1] - ans
    for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

num_p = len(P)
num_n = len(N)
if num_p == 0:
    solve_n(A)
elif num_n == 0:
    solve_p(A)
elif num_p == 1:
    solve1(P, N)
elif num_n == 1:
    solve2(P, N)
else:
    solve3(P, N) l = input().split() l input().split() ().split () input split n = int(l[0]) n int(l[0]) int l[0] l 0 l = input().split() l input().split() ().split () input split int(x) for x in l for x in l x l for x in l int(x) int x A = [int(x) for x in l] A [int(x) for x in l] A.sort() A.sort A sort P = [] P [] N = [] N [] for a in A:
    if a >= 0:
        P.append(a)
    else:
        N.append(a) a A if a >= 0:
        P.append(a)
    else:
        N.append(a) a >= 0 a 0 P.append(a) P.append P append a N.append(a) N.append N append a def print_ans(ans, pairs):
    print(ans)
    for p in pairs:
        print(p[0], p[1]) print_ans print(ans) print ans for p in pairs:
        print(p[0], p[1]) p pairs print(p[0], p[1]) print p[0] p 0 p[1] p 1 ans ans pairs pairs def solve_p(A):
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((A[n - 1], ans))
    ans = A[n - 1] - ans
    print_ans(ans, pairs) solve_p ans = A[0] ans A[0] A 0 pairs = [] pairs [] for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

     i range(1, n - 1) range 1 n - 1 n 1 pairs.append((ans, A[i])) pairs.append pairs append (ans, A[i]) ans A[i] A i ans -= A[i] ans A[i] A i pairs.append((A[n - 1], ans)) pairs.append pairs append (A[n - 1], ans) A[n - 1] A n - 1 n 1 ans ans = A[n - 1] - ans ans A[n - 1] - ans A[n - 1] A n - 1 n 1 ans print_ans(ans, pairs) print_ans ans pairs A A def solve_n(A):
    A.sort(key=lambda x: -x)
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((ans, A[n - 1]))
    ans -= A[-1]
    print_ans(ans, pairs)

# #P == 1 solve_n A.sort(key=lambda x: -x) A.sort A sort key=lambda x: -x key lambda x: -x -x x x ans = A[0] ans A[0] A 0 pairs = [] pairs [] for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

     i range(1, n - 1) range 1 n - 1 n 1 pairs.append((ans, A[i])) pairs.append pairs append (ans, A[i]) ans A[i] A i ans -= A[i] ans A[i] A i pairs.append((ans, A[n - 1])) pairs.append pairs append (ans, A[n - 1]) ans A[n - 1] A n - 1 n 1 ans -= A[-1] ans A[-1] A -1 print_ans(ans, pairs) print_ans ans pairs A A def solve1(P, N):
    ans = P[0]
    pairs = []
    for n in N:
        pairs.append((ans, n))
        ans -= n
    print_ans(ans, pairs)

# #N == 1 #P > 1 solve1 ans = P[0] ans P[0] P 0 pairs = [] pairs [] for n in N:
        pairs.append((ans, n))
        ans -= n
     n N pairs.append((ans, n)) pairs.append pairs append (ans, n) ans n ans -= n ans n print_ans(ans, pairs) print_ans ans pairs P P N N def solve2(P, N):
    ans = N[0]
    pairs = []
    for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

# #P > #N solve2 ans = N[0] ans N[0] N 0 pairs = [] pairs [] for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
     i range(len(P) - 1) range len(P) - 1 len(P) len P 1 pairs.append((ans, P[i])) pairs.append pairs append (ans, P[i]) ans P[i] P i ans -= P[i] ans P[i] P i pairs.append((P[-1], ans)) pairs.append pairs append (P[-1], ans) P[-1] P -1 ans ans = P[-1] - ans ans P[-1] - ans P[-1] P -1 ans print_ans(ans, pairs) print_ans ans pairs P P N N def solve3(P, N):
    num_p = len(P)
    num_n = len(N)
    ans = P[0]
    pairs = []
    for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
    pairs.append((N[-1], ans))
    ans = N[-1] - ans
    for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs) solve3 num_p = len(P) num_p len(P) len P num_n = len(N) num_n len(N) len N ans = P[0] ans P[0] P 0 pairs = [] pairs [] for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
     i range(num_n - 1) range num_n - 1 num_n 1 pairs.append((ans, N[i])) pairs.append pairs append (ans, N[i]) ans N[i] N i ans -= N[i] ans N[i] N i pairs.append((N[-1], ans)) pairs.append pairs append (N[-1], ans) N[-1] N -1 ans ans = N[-1] - ans ans N[-1] - ans N[-1] N -1 ans for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
     i range(1, num_p - 1) range 1 num_p - 1 num_p 1 pairs.append((ans, P[i])) pairs.append pairs append (ans, P[i]) ans P[i] P i ans -= P[i] ans P[i] P i pairs.append((P[-1], ans)) pairs.append pairs append (P[-1], ans) P[-1] P -1 ans ans = P[-1] - ans ans P[-1] - ans P[-1] P -1 ans print_ans(ans, pairs) print_ans ans pairs P P N N num_p = len(P) num_p len(P) len P num_n = len(N) num_n len(N) len N if num_p == 0:
    solve_n(A)
elif num_n == 0:
    solve_p(A)
elif num_p == 1:
    solve1(P, N)
elif num_n == 1:
    solve2(P, N)
else:
    solve3(P, N) num_p == 0 num_p 0 solve_n(A) solve_n A elif num_n == 0:
    solve_p(A) num_n == 0 num_n 0 solve_p(A) solve_p A elif num_p == 1:
    solve1(P, N) num_p == 1 num_p 1 solve1(P, N) solve1 P N elif num_n == 1:
    solve2(P, N) num_n == 1 num_n 1 solve2(P, N) solve2 P N solve3(P, N) solve3 P N l = input().split() input().split() l num_n = len(N) len(N) num_n num_p = len(P) len(P) num_p P = [] [] P l = input().split() input().split() l def solve_n(A):
    A.sort(key=lambda x: -x)
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((ans, A[n - 1]))
    ans -= A[-1]
    print_ans(ans, pairs)

# #P == 1 def solve_n(A):
    A.sort(key=lambda x: -x)
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((ans, A[n - 1]))
    ans -= A[-1]
    print_ans(ans, pairs)

# #P == 1 solve_n def solve_p(A):
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((A[n - 1], ans))
    ans = A[n - 1] - ans
    print_ans(ans, pairs) def solve_p(A):
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((A[n - 1], ans))
    ans = A[n - 1] - ans
    print_ans(ans, pairs) solve_p def solve3(P, N):
    num_p = len(P)
    num_n = len(N)
    ans = P[0]
    pairs = []
    for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
    pairs.append((N[-1], ans))
    ans = N[-1] - ans
    for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs) def solve3(P, N):
    num_p = len(P)
    num_n = len(N)
    ans = P[0]
    pairs = []
    for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
    pairs.append((N[-1], ans))
    ans = N[-1] - ans
    for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs) solve3 def solve1(P, N):
    ans = P[0]
    pairs = []
    for n in N:
        pairs.append((ans, n))
        ans -= n
    print_ans(ans, pairs)

# #N == 1 #P > 1 def solve1(P, N):
    ans = P[0]
    pairs = []
    for n in N:
        pairs.append((ans, n))
        ans -= n
    print_ans(ans, pairs)

# #N == 1 #P > 1 solve1 n = int(l[0]) int(l[0]) n N = [] [] N A = [int(x) for x in l] [int(x) for x in l] A def print_ans(ans, pairs):
    print(ans)
    for p in pairs:
        print(p[0], p[1]) def print_ans(ans, pairs):
    print(ans)
    for p in pairs:
        print(p[0], p[1]) print_ans def solve2(P, N):
    ans = N[0]
    pairs = []
    for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

# #P > #N def solve2(P, N):
    ans = N[0]
    pairs = []
    for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

# #P > #N solve2
l = input().split()
n = int(l[0])

l = input().split()
A = [int(x) for x in l]

# print(N, A)

A.sort()
P = []
N = []
for a in A:
    if a >= 0:
        P.append(a)
    else:
        N.append(a)

def print_ans(ans, pairs):
    print(ans)
    for p in pairs:
        print(p[0], p[1])

def solve_p(A):
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((A[n - 1], ans))
    ans = A[n - 1] - ans
    print_ans(ans, pairs)

def solve_n(A):
    A.sort(key=lambda x: -x)
    ans = A[0]
    pairs = []
    for i in range(1, n - 1):
        pairs.append((ans, A[i]))
        ans -= A[i]

    pairs.append((ans, A[n - 1]))
    ans -= A[-1]
    print_ans(ans, pairs)

# #P == 1
def solve1(P, N):
    ans = P[0]
    pairs = []
    for n in N:
        pairs.append((ans, n))
        ans -= n
    print_ans(ans, pairs)

# #N == 1 #P > 1
def solve2(P, N):
    ans = N[0]
    pairs = []
    for i in range(len(P) - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

# #P > #N
def solve3(P, N):
    num_p = len(P)
    num_n = len(N)
    ans = P[0]
    pairs = []
    for i in range(num_n - 1):
        pairs.append((ans, N[i]))
        ans -= N[i]
    pairs.append((N[-1], ans))
    ans = N[-1] - ans
    for i in range(1, num_p - 1):
        pairs.append((ans, P[i]))
        ans -= P[i]
    pairs.append((P[-1], ans))
    ans = P[-1] - ans
    print_ans(ans, pairs)

num_p = len(P)
num_n = len(N)
if num_p == 0:
    solve_n(A)
elif num_n == 0:
    solve_p(A)
elif num_p == 1:
    solve1(P, N)
elif num_n == 1:
    solve2(P, N)
else:
    solve3(P, N)
