N = int(eval(input()))

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



x = []

y = []

P = sorted((a for a in A if a >= 0), reverse=True)

Q = sorted(a for a in A if a < 0)

if not Q:

    M = sum(P[:-2]) + (P[-2] - P[-1])

    for _ in range(N - 2):

        X = P.pop()

        Y = P.pop()

        x.append(X)

        y.append(Y)

        P.append(X - Y)

    Y = P.pop()

    X = P.pop()

    x.append(X)

    y.append(Y)

elif not P:

    M = -sum(Q[:-2]) - (Q[-2] - Q[-1])

    for _ in range(N - 1):

        X = Q.pop()

        Y = Q.pop()

        x.append(X)

        y.append(Y)

        Q.append(X - Y)

else:

    M = sum(abs(a) for a in A)

    for _ in range(N - 1):

        if len(P) == 1:

            X = P.pop()

            Y = Q.pop()

            x.append(X)

            y.append(Y)

            P.append(X - Y)

        else:

            X = Q.pop()

            Y = P.pop()

            x.append(X)

            y.append(Y)

            Q.append(X - Y)



print(M)

for X, Y in zip(x, y):

    print(('{} {}'.format(X, Y)))

# 入力

N = int(eval(input()))

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



# 正-負をなるべく多く達成するように操作する

P = sorted((a for a in A if a >= 0), reverse=True)

Q = sorted(a for a in A if a < 0)



x, y = [], []

if len(P) == 2 and not Q:

    Y, X = P.pop(), P.pop()

    x.append(X)

    y.append(Y)

    P.append(X - Y)

if len(P) >= 3 and not Q:

    X, Y = P.pop(), P.pop()

    x.append(X)

    y.append(Y)

    Q.append(X - Y)

if not P and len(Q) >= 2:

    X, Y = Q.pop(), Q.pop()

    x.append(X)

    y.append(Y)

    P.append(X - Y)

while len(P) >= 2 and Q:

    X, Y = Q.pop(), P.pop()

    x.append(X)

    y.append(Y)

    Q.append(X - Y)

while Q:

    X, Y = P.pop(), Q.pop()

    x.append(X)

    y.append(Y)

    P.append(X - Y)



ans = (

    '{}\n{}'.format(

        P[0],

        '\n'.join(

            '{} {}'.format(X, Y)

            for X, Y in zip(x, y)

        )

    )

)



# 出力

print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
x = []
y = []
P = sorted((a for a in A if a >= 0), reverse=True)
Q = sorted(a for a in A if a < 0)
if not Q:
    M = sum(P[:-2]) + (P[-2] - P[-1])
    for _ in range(N - 2):
        X = P.pop()
        Y = P.pop()
        x.append(X)
        y.append(Y)
        P.append(X - Y)
    Y = P.pop()
    X = P.pop()
    x.append(X)
    y.append(Y)
elif not P:
    M = -sum(Q[:-2]) - (Q[-2] - Q[-1])
    for _ in range(N - 1):
        X = Q.pop()
        Y = Q.pop()
        x.append(X)
        y.append(Y)
        Q.append(X - Y)
else:
    M = sum(abs(a) for a in A)
    for _ in range(N - 1):
        if len(P) == 1:
            X = P.pop()
            Y = Q.pop()
            x.append(X)
            y.append(Y)
            P.append(X - Y)
        else:
            X = Q.pop()
            Y = P.pop()
            x.append(X)
            y.append(Y)
            Q.append(X - Y)
print(M)
for X, Y in zip(x, y):
    print(("{} {}".format(X, Y)))

# 入力
N = int(eval(input()))
A = list(map(int, input().split()))
# 正-負をなるべく多く達成するように操作する
P = sorted((a for a in A if a >= 0), reverse=True)
Q = sorted(a for a in A if a < 0)
x, y = [], []
if len(P) == 2 and not Q:
    Y, X = P.pop(), P.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)
if len(P) >= 3 and not Q:
    X, Y = P.pop(), P.pop()
    x.append(X)
    y.append(Y)
    Q.append(X - Y)
if not P and len(Q) >= 2:
    X, Y = Q.pop(), Q.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)
while len(P) >= 2 and Q:
    X, Y = Q.pop(), P.pop()
    x.append(X)
    y.append(Y)
    Q.append(X - Y)
while Q:
    X, Y = P.pop(), Q.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)
ans = "{}\n{}".format(P[0], "\n".join("{} {}".format(X, Y) for X, Y in zip(x, y)))
# 出力
print(ans)

+# 入力 -x = [] -y = [] +# 正-負をなるべく多く達成するように操作する -if not Q: -    M = sum(P[:-2]) + (P[-2] - P[-1]) -    for _ in range(N - 2): -        X = P.pop() -        Y = P.pop() -        x.append(X) -        y.append(Y) -        P.append(X - Y) -    Y = P.pop() -    X = P.pop() +x, y = [], [] +if len(P) == 2 and not Q: +    Y, X = P.pop(), P.pop() -elif not P: -    M = -sum(Q[:-2]) - (Q[-2] - Q[-1]) -    for _ in range(N - 1): -        X = Q.pop() -        Y = Q.pop() -        x.append(X) -        y.append(Y) -        Q.append(X - Y) -else: -    M = sum(abs(a) for a in A) -    for _ in range(N - 1): -        if len(P) == 1: -            X = P.pop() -            Y = Q.pop() -            x.append(X) -            y.append(Y) -            P.append(X - Y) -        else: -            X = Q.pop() -            Y = P.pop() -            x.append(X) -            y.append(Y) -            Q.append(X - Y) -print(M) -for X, Y in zip(x, y): -    print(("{} {}".format(X, Y))) +    P.append(X - Y) +if len(P) >= 3 and not Q: +    X, Y = P.pop(), P.pop() +    x.append(X) +    y.append(Y) +    Q.append(X - Y) +if not P and len(Q) >= 2: +    X, Y = Q.pop(), Q.pop() +    x.append(X) +    y.append(Y) +    P.append(X - Y) +while len(P) >= 2 and Q: +    X, Y = Q.pop(), P.pop() +    x.append(X) +    y.append(Y) +    Q.append(X - Y) +while Q: +    X, Y = P.pop(), Q.pop() +    x.append(X) +    y.append(Y) +    P.append(X - Y) +ans = "{}\n{}".format(P[0], "\n".join("{} {}".format(X, Y) for X, Y in zip(x, y))) +# 出力 +print(ans)