
def solve():
    N = int(raw_input())
    A = [int(_) for _ in raw_input().split()]
    A.sort()
    ret = abs(A[N-1] - A[0])
    rever = [0] * (N - 1)
    for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
    print ret
    def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

    cnt = 0
    if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
    cnt += 1
    for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1

if __name__ == '__main__':
    solve() def solve():
    N = int(raw_input())
    A = [int(_) for _ in raw_input().split()]
    A.sort()
    ret = abs(A[N-1] - A[0])
    rever = [0] * (N - 1)
    for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
    print ret
    def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

    cnt = 0
    if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
    cnt += 1
    for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1 solve N = int(raw_input()) N int(raw_input()) int raw_input() raw_input int(_) for _ in raw_input().split() for _ in raw_input().split() _ raw_input().split() ().split () raw_input split for _ in raw_input().split() int(_) int _ A = [int(_) for _ in raw_input().split()] A [int(_) for _ in raw_input().split()] A.sort() A.sort A sort ret = abs(A[N-1] - A[0]) ret abs(A[N-1] - A[0]) abs A[N-1] - A[0] A[N-1] A N-1 N 1 A[0] A 0 rever = [0] * (N - 1) rever [0] * (N - 1) [0] 0 N - 1 N 1 for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
     i range(1, N-1) range 1 N-1 N 1 if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
     A[i] >= 0 A[i] A i 0 ret = ret + A[i] ret ret + A[i] ret A[i] A i rever[i-1] = 1 rever[i-1] rever i-1 i 1 1 ret = ret - A[i] ret ret - A[i] ret A[i] A i print def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

     PrintAndCalcSave if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

     rever == 0 rever 0 print a b return a - b a - b a b print b a return b - a b - a b a a a b b rever rever cnt = 0 cnt 0 if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
     A[N-1] > A[0] A[N-1] A N-1 N 1 A[0] A 0 save = PrintAndCalcSave(A[N-1], A[0], rever[cnt]) save PrintAndCalcSave(A[N-1], A[0], rever[cnt]) PrintAndCalcSave A[N-1] A N-1 N 1 A[0] A 0 rever[cnt] rever cnt save = PrintAndCalcSave(A[0], A[N-1], rever[cnt]) save PrintAndCalcSave(A[0], A[N-1], rever[cnt]) PrintAndCalcSave A[0] A 0 A[N-1] A N-1 N 1 rever[cnt] rever cnt cnt += 1 cnt 1 for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1 i range(1, N - 1) range 1 N - 1 N 1 if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
         A[i] >= 0 A[i] A i 0 save = PrintAndCalcSave(A[i], save, rever[cnt]) save PrintAndCalcSave(A[i], save, rever[cnt]) PrintAndCalcSave A[i] A i save rever[cnt] rever cnt save = PrintAndCalcSave(save, A[i], rever[cnt]) save PrintAndCalcSave(save, A[i], rever[cnt]) PrintAndCalcSave save A[i] A i rever[cnt] rever cnt cnt += 1 cnt 1 if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    N = int(raw_input())
    A = [int(_) for _ in raw_input().split()]
    A.sort()
    ret = abs(A[N-1] - A[0])
    rever = [0] * (N - 1)
    for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
    print ret
    def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

    cnt = 0
    if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
    cnt += 1
    for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1 def solve():
    N = int(raw_input())
    A = [int(_) for _ in raw_input().split()]
    A.sort()
    ret = abs(A[N-1] - A[0])
    rever = [0] * (N - 1)
    for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
    print ret
    def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

    cnt = 0
    if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
    cnt += 1
    for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1 solve

def solve():
    N = int(raw_input())
    A = [int(_) for _ in raw_input().split()]
    A.sort()
    ret = abs(A[N-1] - A[0])
    rever = [0] * (N - 1)
    for i in range(1, N-1):
        if A[i] >= 0:
            ret = ret + A[i]
            rever[i-1] = 1
        else:
            ret = ret - A[i]
    print ret
    def PrintAndCalcSave(a, b, rever):
        if rever == 0:
            print a, b
            return a - b
        else:
            print b, a
            return b - a

    cnt = 0
    if A[N-1] > A[0]:
        save = PrintAndCalcSave(A[N-1], A[0], rever[cnt])
    else:
        save = PrintAndCalcSave(A[0], A[N-1], rever[cnt])
    cnt += 1
    for i in range(1, N - 1):
        if A[i] >= 0:
            save = PrintAndCalcSave(A[i], save, rever[cnt])
        else:
            save = PrintAndCalcSave(save, A[i], rever[cnt])
        cnt += 1

if __name__ == '__main__':
    solve()
