import bisect



N = int(eval(input()))

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



i = bisect.bisect_left(A, 0)

j = bisect.bisect_right(A, 0)

if i == j:

    if i == 0:

        negatives = A[:1]

        positives = A[1:]

    elif i == N:

        negatives = A[:-1]

        positives = A[-1:]

    else:

        negatives = A[:i]

        positives = A[i:]



else:

    m = max((i+j)//2, 1)

    negatives = A[:m]

    positives = A[m:]





score = sum(positives) - sum(negatives)

print(score)



def it():



    def balanced(pos, neg):

        y = neg.pop()

        x = pos.pop()

        yield (x,y)

        y = x-y

        while pos and neg:

            x = neg.pop()

            yield (x,y)

            y = x-y

            x = pos.pop()

            yield (x,y)

            y = x-y



    if len(positives) < len(negatives):



        x = positives.pop()



        while len(positives)+1 < len(negatives):

            y = negatives.pop()

            yield (x,y)

            x -= y

        positives.append(x)

    elif len(positives) > len(negatives):

        x = negatives.pop()



        while len(negatives)+1 < len(positives):

            y = positives.pop()

            yield (x,y)

            x -= y

        negatives.append(x)



    for x,y in balanced(positives, negatives):

        yield x,y





for x,y in it():

    print((x,y))





















from bisect import bisect



def solve():

    N = int(eval(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)))
import bisect

N = int(eval(input()))
A = sorted(map(int, input().split()))
i = bisect.bisect_left(A, 0)
j = bisect.bisect_right(A, 0)
if i == j:
    if i == 0:
        negatives = A[:1]
        positives = A[1:]
    elif i == N:
        negatives = A[:-1]
        positives = A[-1:]
    else:
        negatives = A[:i]
        positives = A[i:]
else:
    m = max((i + j) // 2, 1)
    negatives = A[:m]
    positives = A[m:]
score = sum(positives) - sum(negatives)
print(score)


def it():
    def balanced(pos, neg):
        y = neg.pop()
        x = pos.pop()
        yield (x, y)
        y = x - y
        while pos and neg:
            x = neg.pop()
            yield (x, y)
            y = x - y
            x = pos.pop()
            yield (x, y)
            y = x - y

    if len(positives) < len(negatives):
        x = positives.pop()
        while len(positives) + 1 < len(negatives):
            y = negatives.pop()
            yield (x, y)
            x -= y
        positives.append(x)
    elif len(positives) > len(negatives):
        x = negatives.pop()
        while len(negatives) + 1 < len(positives):
            y = positives.pop()
            yield (x, y)
            x -= y
        negatives.append(x)
    for x, y in balanced(positives, negatives):
        yield x, y


for x, y in it():
    print((x, y))

from bisect import bisect


def solve():
    N = int(eval(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)))

-import bisect - -N = int(eval(input())) -A = sorted(map(int, input().split())) -i = bisect.bisect_left(A, 0) -j = bisect.bisect_right(A, 0) -if i == j: -    if i == 0: -        negatives = A[:1] -        positives = A[1:] -    elif i == N: -        negatives = A[:-1] -        positives = A[-1:] -    else: -        negatives = A[:i] -        positives = A[i:] -else: -    m = max((i + j) // 2, 1) -    negatives = A[:m] -    positives = A[m:] -score = sum(positives) - sum(negatives) -print(score) +from bisect import bisect -def it(): -    def balanced(pos, neg): -        y = neg.pop() -        x = pos.pop() -        yield (x, y) -        y = x - y -        while pos and neg: -            x = neg.pop() -            yield (x, y) -            y = x - y -            x = pos.pop() -            yield (x, y) -            y = x - y - -    if len(positives) < len(negatives): -        x = positives.pop() -        while len(positives) + 1 < len(negatives): -            y = negatives.pop() -            yield (x, y) -            x -= y -        positives.append(x) -    elif len(positives) > len(negatives): -        x = negatives.pop() -        while len(negatives) + 1 < len(positives): -            y = positives.pop() -            yield (x, y) -            x -= y -        negatives.append(x) -    for x, y in balanced(positives, negatives): -        yield x, y +def solve(): +    N = int(eval(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) -for x, y in it(): -    print((x, y)) +s, res = solve() +print(s) +print(("\n".join(f"{a} {b}" for a, b in res)))