N = int(input())
A = [int(_) for _ in input().split()]

mxs = sorted(x for x in A if x < 0)
pxs = sorted(x for x in A if x >= 0)

if len(mxs) == 0:
    mxs = [pxs[0]]
    pxs = pxs[1:]

if len(pxs) == 0:
    pxs = [mxs[-1]]
    mxs = mxs[:-1]

#print(mxs, pxs)

result = sum(pxs) - sum(mxs)
print(result)

if len(pxs) == 1:
    for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y
else:
    for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
    print(pxs[-1], mxs[0])
    pxs[-1] -= mxs[0]
    for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range


 N = int(input()) N int(input()) int input() input int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ A = [int(_) for _ in input().split()] A [int(_) for _ in input().split()] mxs = sorted(x for x in A if x < 0) mxs sorted(x for x in A if x < 0) sorted x pxs = sorted(x for x in A if x >= 0) pxs sorted(x for x in A if x >= 0) sorted x if len(mxs) == 0:
    mxs = [pxs[0]]
    pxs = pxs[1:] len(mxs) == 0 len(mxs) len mxs 0 mxs = [pxs[0]] mxs [pxs[0]] pxs[0] pxs 0 pxs = pxs[1:] pxs pxs[1:] pxs 1: 1 if len(pxs) == 0:
    pxs = [mxs[-1]]
    mxs = mxs[:-1]

#print(mxs, pxs) len(pxs) == 0 len(pxs) len pxs 0 pxs = [mxs[-1]] pxs [mxs[-1]] mxs[-1] mxs -1 mxs = mxs[:-1] mxs mxs[:-1] mxs :-1 -1 result = sum(pxs) - sum(mxs) result sum(pxs) - sum(mxs) sum(pxs) sum pxs sum(mxs) sum mxs print(result) print result if len(pxs) == 1:
    for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y
else:
    for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
    print(pxs[-1], mxs[0])
    pxs[-1] -= mxs[0]
    for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range len(pxs) == 1 len(pxs) len pxs 1 for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y y mxs print(pxs[0], y) print pxs[0] pxs 0 y pxs[0] -= y pxs[0] pxs 0 y for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
     y pxs[:-1] pxs :-1 -1 print(mxs[0], y) print mxs[0] mxs 0 y mxs[0] -= y mxs[0] mxs 0 y print(pxs[-1], mxs[0]) print pxs[-1] pxs -1 mxs[0] mxs 0 pxs[-1] -= mxs[0] pxs[-1] pxs -1 mxs[0] mxs 0 for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range y mxs[1:] mxs 1: 1 print(pxs[-1], y) print pxs[-1] pxs -1 y pxs[-1] -= y pxs[-1] pxs -1 y A = [int(_) for _ in input().split()] [int(_) for _ in input().split()] A mxs = sorted(x for x in A if x < 0) sorted(x for x in A if x < 0) mxs result = sum(pxs) - sum(mxs) sum(pxs) - sum(mxs) result pxs = pxs[1:] pxs[1:] pxs mxs = [pxs[0]] [pxs[0]] mxs pxs = [mxs[-1]] [mxs[-1]] pxs mxs = mxs[:-1] mxs[:-1] mxs pxs = sorted(x for x in A if x >= 0) sorted(x for x in A if x >= 0) pxs N = int(input()) int(input()) N
N = int(input())
A = [int(_) for _ in input().split()]

mxs = sorted(x for x in A if x < 0)
pxs = sorted(x for x in A if x >= 0)

if len(mxs) == 0:
    mxs = [pxs[0]]
    pxs = pxs[1:]

if len(pxs) == 0:
    pxs = [mxs[-1]]
    mxs = mxs[:-1]

#print(mxs, pxs)

result = sum(pxs) - sum(mxs)
print(result)

if len(pxs) == 1:
    for y in mxs:
        print(pxs[0], y)
        pxs[0] -= y
else:
    for y in pxs[:-1]:
        print(mxs[0], y)
        mxs[0] -= y
    print(pxs[-1], mxs[0])
    pxs[-1] -= mxs[0]
    for y in mxs[1:]:
        print(pxs[-1], y)
        pxs[-1] -= y

#for i in range



