N, *A = list(map(int, open(0).read().split()))



x = sorted([v for v in A if v >= 0])

y = sorted([v for v in A if v < 0], reverse=True)



ans = []

if len(y) == 0:

    cnt = x[0]

    for v in x[1:-1]:

        ans.append((cnt, v))

        cnt -= v

    ans.append((x[-1], cnt))

    print((x[-1] - cnt))

elif len(x) == 0:

    cnt = y[0]

    for v in y[1:]:

        ans.append((cnt, v))

        cnt -= v

    print(cnt)

else:

    for v in x[:-1]:

        ans.append((y[0], v))

        y[0] -= v

        

    cnt = x[-1]

    for v in y:

        ans.append((cnt, v))

        cnt -= v

    print(cnt)

    

for v in ans:

    print((*v))


N = int(eval(input()))

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



pos = sorted([v for v in X if v >= 0])

neg = sorted([v for v in X if v < 0], reverse=True)



ans = []

if not neg:

    # neg is empty

    cnt = pos[0]

    for v in pos[1:-1]:

        ans.append((cnt, v))

        cnt -= v

    ans.append((pos[-1], cnt))

    print((pos[-1] - cnt))

elif not pos:

    # pos is empty

    cnt = neg[0]

    for v in neg[1:]:

        ans.append((cnt, v))

        cnt -= v

    print(cnt)

else:

    # neg and pos exist

    for v in pos[:-1]:

        ans.append((neg[0], v))

        neg[0] -= v



    cnt = pos[-1]

    for v in neg:

        ans.append((cnt, v))

        cnt -= v

    print(cnt)



for v in ans:

    print((*v))

N, *A = list(map(int, open(0).read().split()))
x = sorted([v for v in A if v >= 0])
y = sorted([v for v in A if v < 0], reverse=True)
ans = []
if len(y) == 0:
    cnt = x[0]
    for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((x[-1], cnt))
    print((x[-1] - cnt))
elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    for v in x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
    cnt = x[-1]
    for v in y:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
for v in ans:
    print((*v))

N = int(eval(input()))
X = list(map(int, input().split()))
pos = sorted([v for v in X if v >= 0])
neg = sorted([v for v in X if v < 0], reverse=True)
ans = []
if not neg:
    # neg is empty
    cnt = pos[0]
    for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((pos[-1], cnt))
    print((pos[-1] - cnt))
elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    # neg and pos exist
    for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v
    cnt = pos[-1]
    for v in neg:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
for v in ans:
    print((*v))

-N, *A = list(map(int, open(0).read().split())) -x = sorted([v for v in A if v >= 0]) -y = sorted([v for v in A if v < 0], reverse=True) +N = int(eval(input())) +X = list(map(int, input().split())) +pos = sorted([v for v in X if v >= 0]) +neg = sorted([v for v in X if v < 0], reverse=True) -if len(y) == 0: -    cnt = x[0] -    for v in x[1:-1]: +if not neg: +    # neg is empty +    cnt = pos[0] +    for v in pos[1:-1]: -    ans.append((x[-1], cnt)) -    print((x[-1] - cnt)) -elif len(x) == 0: -    cnt = y[0] -    for v in y[1:]: +    ans.append((pos[-1], cnt)) +    print((pos[-1] - cnt)) +elif not pos: +    # pos is empty +    cnt = neg[0] +    for v in neg[1:]: -    for v in x[:-1]: -        ans.append((y[0], v)) -        y[0] -= v -    cnt = x[-1] -    for v in y: +    # neg and pos exist +    for v in pos[:-1]: +        ans.append((neg[0], v)) +        neg[0] -= v +    cnt = pos[-1] +    for v in neg: