from bisect import bisect

def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res)



s,res = solve()
print(s)
print('\n'.join(f'{a} {b}' for a,b in res)) from bisect import bisect def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res) solve N = int(input()) N int(input()) int input() input A = sorted(map(int,input().split())) A sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

     N == 2 N 2 res = [(max(A),min(A))] res [(max(A),min(A))] (max(A),min(A)) max(A) max A min(A) min A s = max(A)-min(A) s max(A)-min(A) max(A) max A min(A) min A return s, res return s, res s res if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
     A[0] >= 0 A[0] A 0 0 res = [] res [] x = A[0] x A[0] A 0 for a in A[1:-1]:
            res.append((x,a))
            x -= a
         a A[1:-1] A 1:-1 1 -1 res.append((x,a)) res.append res append (x,a) x a x -= a x a res.append((A[-1],x)) res.append res append (A[-1],x) A[-1] A -1 x x = A[-1]-x x A[-1]-x A[-1] A -1 x return (x,res) (x,res) x res if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

     A[-1] <= 0 A[-1] A -1 0 res = [] res [] x = A[-1] x A[-1] A -1 for a in A[:-1]:
            res.append((x,a))
            x -= a
         a A[:-1] A :-1 -1 res.append((x,a)) res.append res append (x,a) x a x -= a x a return (x,res) (x,res) x res res = [] res [] p = bisect(A,0)-1 p bisect(A,0)-1 bisect(A,0) bisect A 0 1 x = A[p] x A[p] A p for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
     a A[p+1:N-1] A p+1:N-1 p+1 p 1 N-1 N 1 res.append((x,a)) res.append res append (x,a) x a x -= a x a res.append((A[-1],x)) res.append res append (A[-1],x) A[-1] A -1 x x = A[-1]-x x A[-1]-x A[-1] A -1 x for a in A[:p]:
        res.append((x,a))
        x -= a
     a A[:p] A :p p res.append((x,a)) res.append res append (x,a) x a x -= a x a return (x,res) (x,res) x res s,res = solve() s solve() solve res print(s) print s print('\n'.join(f'{a} {b}' for a,b in res)) print '\n'.join(f'{a} {b}' for a,b in res) '\n'.join '\n' join f'{a} {b}' res = solve() solve() res s,res = solve() solve() s def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res) def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res) solve
from bisect import bisect

def solve():
    N = int(input())
    A = sorted(map(int,input().split()))
    if N == 2:
        res = [(max(A),min(A))]
        s = max(A)-min(A)
        return s, res

    if A[0] >= 0:
        res = []
        x = A[0]
        for a in A[1:-1]:
            res.append((x,a))
            x -= a
        res.append((A[-1],x))
        x = A[-1]-x
        return (x,res)
    if A[-1] <= 0:
        res = []
        x = A[-1]
        for a in A[:-1]:
            res.append((x,a))
            x -= a
        return (x,res)

    res = []
    p = bisect(A,0)-1
    x = A[p]
    for a in A[p+1:N-1]:
        res.append((x,a))
        x -= a
    res.append((A[-1],x))
    x = A[-1]-x
    for a in A[:p]:
        res.append((x,a))
        x -= a
    return (x,res)



s,res = solve()
print(s)
print('\n'.join(f'{a} {b}' for a,b in res))