N = int(input())
AA = list(map(int,input().split()))#0を含む可能性あり

A = []
count = 0
for i in range(N):
    if AA[i] != 0:
        A.append(AA[i])
    else:
        count += 1

NN = N - count
B = [abs(A[i]) for i in range(NN)]

if count == 0:
    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    if det == 1:#全て同符号
        m = min(B)

        M = sum(B) - 2 * m
        print(M)

        for i in range(NN):
            if m == B[i]:
                p = i
                break

        C = [A[i]//B[i] for i in range(NN)]

        C[p] *= -1

    else:#異符号が含まれる
        M = sum(B)
        print(M)
        C = [A[i]//B[i] for i in range(NN)]

    fp = -1 #firstplus
    fm = -1 #firstminus
    for i in range(NN):
        if fp == -1 and C[i] == 1:
            fp = i
        elif fm == -1 and C[i] == -1:
            fm = i
        elif fp != -1 and fm != -1:
            break

    X = []
    Y = []

    for i in range(NN):
        if i == fp or i == fm:
            continue
        if C[i] == -1:
            X.append(i)
        else:
            Y.append(i)

    x = A[fp]
    for i in X:
        print(x,A[i])
        x -= A[i]

    y = A[fm]
    for i in Y:
        print(y,A[i])
        y -= A[i]

    print(x,y)

elif A == []:
    print(0)
    for i in range(count-1):
        print(0,0)

else:

    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    M = sum(B)
    print(M)

    if det == 1:#全て同符号
        #これがまずい
        if s < 0:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN):
                print(x,A[i])
                x -= A[i]
        else:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
            print(A[NN-1],x)
            




    else:#異符号が含まれる
        #こちらは今まで通り処理して最後に0を引きまくれば良い
        
        C = [A[i]//B[i] for i in range(NN)]

        fp = -1 #firstplus
        fm = -1 #firstminus
        for i in range(NN):
            if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

        X = []
        Y = []

        for i in range(NN):
            if i == fp or i == fm:
                continue
            if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

        x = A[fp]
        for i in X:
            print(x,A[i])
            x -= A[i]

        y = A[fm]
        for i in Y:
            print(y,A[i])
            y -= A[i]

        print(x,y)

        for i in range(count):
            print(x-y,0) N = int(input()) N int(input()) int input() input AA = list(map(int,input().split())) AA list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split A = [] A [] count = 0 count 0 for i in range(N):
    if AA[i] != 0:
        A.append(AA[i])
    else:
        count += 1 i range(N) range N if AA[i] != 0:
        A.append(AA[i])
    else:
        count += 1 AA[i] != 0 AA[i] AA i 0 A.append(AA[i]) A.append A append AA[i] AA i count += 1 count 1 NN = N - count NN N - count N count abs(A[i]) for i in range(NN) for i in range(NN) i range(NN) range NN for i in range(NN) abs(A[i]) abs A[i] A i B = [abs(A[i]) for i in range(NN)] B [abs(A[i]) for i in range(NN)] if count == 0:
    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    if det == 1:#全て同符号
        m = min(B)

        M = sum(B) - 2 * m
        print(M)

        for i in range(NN):
            if m == B[i]:
                p = i
                break

        C = [A[i]//B[i] for i in range(NN)]

        C[p] *= -1

    else:#異符号が含まれる
        M = sum(B)
        print(M)
        C = [A[i]//B[i] for i in range(NN)]

    fp = -1 #firstplus
    fm = -1 #firstminus
    for i in range(NN):
        if fp == -1 and C[i] == 1:
            fp = i
        elif fm == -1 and C[i] == -1:
            fm = i
        elif fp != -1 and fm != -1:
            break

    X = []
    Y = []

    for i in range(NN):
        if i == fp or i == fm:
            continue
        if C[i] == -1:
            X.append(i)
        else:
            Y.append(i)

    x = A[fp]
    for i in X:
        print(x,A[i])
        x -= A[i]

    y = A[fm]
    for i in Y:
        print(y,A[i])
        y -= A[i]

    print(x,y)

elif A == []:
    print(0)
    for i in range(count-1):
        print(0,0)

else:

    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    M = sum(B)
    print(M)

    if det == 1:#全て同符号
        #これがまずい
        if s < 0:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN):
                print(x,A[i])
                x -= A[i]
        else:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
            print(A[NN-1],x)
            




    else:#異符号が含まれる
        #こちらは今まで通り処理して最後に0を引きまくれば良い
        
        C = [A[i]//B[i] for i in range(NN)]

        fp = -1 #firstplus
        fm = -1 #firstminus
        for i in range(NN):
            if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

        X = []
        Y = []

        for i in range(NN):
            if i == fp or i == fm:
                continue
            if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

        x = A[fp]
        for i in X:
            print(x,A[i])
            x -= A[i]

        y = A[fm]
        for i in Y:
            print(y,A[i])
            y -= A[i]

        print(x,y)

        for i in range(count):
            print(x-y,0) count == 0 count 0 det = 1 det 1 s = A[0]//B[0] s A[0]//B[0] A[0] A 0 B[0] B 0 for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

     i range(1,NN) range 1 NN if s * A[i] < 0:
            det = -1
            break

     s * A[i] < 0 s * A[i] s A[i] A i 0 det = -1 det -1 break if det == 1:#全て同符号
        m = min(B)

        M = sum(B) - 2 * m
        print(M)

        for i in range(NN):
            if m == B[i]:
                p = i
                break

        C = [A[i]//B[i] for i in range(NN)]

        C[p] *= -1

    else:#異符号が含まれる
        M = sum(B)
        print(M)
        C = [A[i]//B[i] for i in range(NN)]

     det == 1 det 1 m = min(B) m min(B) min B M = sum(B) - 2 * m M sum(B) - 2 * m sum(B) sum B 2 * m 2 m print(M) print M for i in range(NN):
            if m == B[i]:
                p = i
                break

         i range(NN) range NN if m == B[i]:
                p = i
                break

         m == B[i] m B[i] B i p = i p i break A[i]//B[i] for i in range(NN) for i in range(NN) i range(NN) range NN for i in range(NN) A[i]//B[i] A[i] A i B[i] B i C = [A[i]//B[i] for i in range(NN)] C [A[i]//B[i] for i in range(NN)] C[p] *= -1 C[p] C p -1 M = sum(B) M sum(B) sum B print(M) print M A[i]//B[i] for i in range(NN) for i in range(NN) i range(NN) range NN for i in range(NN) A[i]//B[i] A[i] A i B[i] B i C = [A[i]//B[i] for i in range(NN)] C [A[i]//B[i] for i in range(NN)] fp = -1 fp -1 fm = -1 fm -1 for i in range(NN):
        if fp == -1 and C[i] == 1:
            fp = i
        elif fm == -1 and C[i] == -1:
            fm = i
        elif fp != -1 and fm != -1:
            break

     i range(NN) range NN if fp == -1 and C[i] == 1:
            fp = i
        elif fm == -1 and C[i] == -1:
            fm = i
        elif fp != -1 and fm != -1:
            break

     fp == -1 and C[i] == 1 fp == -1 fp -1 C[i] == 1 C[i] C i 1 fp = i fp i elif fm == -1 and C[i] == -1:
            fm = i
         fm == -1 and C[i] == -1 fm == -1 fm -1 C[i] == -1 C[i] C i -1 fm = i fm i elif fp != -1 and fm != -1:
            break

     fp != -1 and fm != -1 fp != -1 fp -1 fm != -1 fm -1 break X = [] X [] Y = [] Y [] for i in range(NN):
        if i == fp or i == fm:
            continue
        if C[i] == -1:
            X.append(i)
        else:
            Y.append(i)

     i range(NN) range NN if i == fp or i == fm:
            continue
         i == fp or i == fm i == fp i fp i == fm i fm continue if C[i] == -1:
            X.append(i)
        else:
            Y.append(i)

     C[i] == -1 C[i] C i -1 X.append(i) X.append X append i Y.append(i) Y.append Y append i x = A[fp] x A[fp] A fp for i in X:
        print(x,A[i])
        x -= A[i]

     i X print(x,A[i]) print x A[i] A i x -= A[i] x A[i] A i y = A[fm] y A[fm] A fm for i in Y:
        print(y,A[i])
        y -= A[i]

     i Y print(y,A[i]) print y A[i] A i y -= A[i] y A[i] A i print(x,y) print x y elif A == []:
    print(0)
    for i in range(count-1):
        print(0,0) A == [] A [] print(0) print 0 for i in range(count-1):
        print(0,0) i range(count-1) range count-1 count 1 print(0,0) print 0 0 det = 1 det 1 s = A[0]//B[0] s A[0]//B[0] A[0] A 0 B[0] B 0 for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

     i range(1,NN) range 1 NN if s * A[i] < 0:
            det = -1
            break

     s * A[i] < 0 s * A[i] s A[i] A i 0 det = -1 det -1 break M = sum(B) M sum(B) sum B print(M) print M if det == 1:#全て同符号
        #これがまずい
        if s < 0:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN):
                print(x,A[i])
                x -= A[i]
        else:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
            print(A[NN-1],x)
            




    else:#異符号が含まれる
        #こちらは今まで通り処理して最後に0を引きまくれば良い
        
        C = [A[i]//B[i] for i in range(NN)]

        fp = -1 #firstplus
        fm = -1 #firstminus
        for i in range(NN):
            if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

        X = []
        Y = []

        for i in range(NN):
            if i == fp or i == fm:
                continue
            if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

        x = A[fp]
        for i in X:
            print(x,A[i])
            x -= A[i]

        y = A[fm]
        for i in Y:
            print(y,A[i])
            y -= A[i]

        print(x,y)

        for i in range(count):
            print(x-y,0) det == 1 det 1 if s < 0:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN):
                print(x,A[i])
                x -= A[i]
        else:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
            print(A[NN-1],x)
            




     s < 0 s 0 for i in range(count-1):
                print(0,0)
             i range(count-1) range count-1 count 1 print(0,0) print 0 0 x = 0 x 0 for i in range(NN):
                print(x,A[i])
                x -= A[i]
         i range(NN) range NN print(x,A[i]) print x A[i] A i x -= A[i] x A[i] A i for i in range(count-1):
                print(0,0)
             i range(count-1) range count-1 count 1 print(0,0) print 0 0 x = 0 x 0 for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
             i range(NN-1) range NN-1 NN 1 print(x,A[i]) print x A[i] A i x -= A[i] x A[i] A i print(A[NN-1],x) print A[NN-1] A NN-1 NN 1 x A[i]//B[i] for i in range(NN) for i in range(NN) i range(NN) range NN for i in range(NN) A[i]//B[i] A[i] A i B[i] B i C = [A[i]//B[i] for i in range(NN)] C [A[i]//B[i] for i in range(NN)] fp = -1 fp -1 fm = -1 fm -1 for i in range(NN):
            if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

         i range(NN) range NN if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

         fp == -1 and C[i] == 1 fp == -1 fp -1 C[i] == 1 C[i] C i 1 fp = i fp i elif fm == -1 and C[i] == -1:
                fm = i
             fm == -1 and C[i] == -1 fm == -1 fm -1 C[i] == -1 C[i] C i -1 fm = i fm i elif fp != -1 and fm != -1:
               break

         fp != -1 and fm != -1 fp != -1 fp -1 fm != -1 fm -1 break X = [] X [] Y = [] Y [] for i in range(NN):
            if i == fp or i == fm:
                continue
            if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

         i range(NN) range NN if i == fp or i == fm:
                continue
             i == fp or i == fm i == fp i fp i == fm i fm continue if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

         C[i] == -1 C[i] C i -1 X.append(i) X.append X append i Y.append(i) Y.append Y append i x = A[fp] x A[fp] A fp for i in X:
            print(x,A[i])
            x -= A[i]

         i X print(x,A[i]) print x A[i] A i x -= A[i] x A[i] A i y = A[fm] y A[fm] A fm for i in Y:
            print(y,A[i])
            y -= A[i]

         i Y print(y,A[i]) print y A[i] A i y -= A[i] y A[i] A i print(x,y) print x y for i in range(count):
            print(x-y,0) i range(count) range count print(x-y,0) print x-y x y 0 Y = [] [] Y x -= A[i] A[i] x det = 1 1 det NN = N - count N - count NN det = -1 -1 det M = sum(B) - 2 * m sum(B) - 2 * m M y -= A[i] A[i] y M = sum(B) sum(B) M fm = -1 -1 fm M = sum(B) sum(B) M s = A[0]//B[0] A[0]//B[0] s count = 0 0 count C = [A[i]//B[i] for i in range(NN)] [A[i]//B[i] for i in range(NN)] C fm = i i fm count += 1 1 count y = A[fm] A[fm] y x -= A[i] A[i] x det = 1 1 det det = -1 -1 det x -= A[i] A[i] x fp = i i fp fp = i i fp fp = -1 -1 fp x -= A[i] A[i] x C = [A[i]//B[i] for i in range(NN)] [A[i]//B[i] for i in range(NN)] C Y = [] [] Y y = A[fm] A[fm] y N = int(input()) int(input()) N X = [] [] X x = A[fp] A[fp] x m = min(B) min(B) m AA = list(map(int,input().split())) list(map(int,input().split())) AA B = [abs(A[i]) for i in range(NN)] [abs(A[i]) for i in range(NN)] B x = A[fp] A[fp] x A = [] [] A s = A[0]//B[0] A[0]//B[0] s fm = -1 -1 fm C = [A[i]//B[i] for i in range(NN)] [A[i]//B[i] for i in range(NN)] C p = i i p x = 0 0 x fm = i i fm X = [] [] X fp = -1 -1 fp y -= A[i] A[i] y x = 0 0 x
N = int(input())
AA = list(map(int,input().split()))#0を含む可能性あり

A = []
count = 0
for i in range(N):
    if AA[i] != 0:
        A.append(AA[i])
    else:
        count += 1

NN = N - count
B = [abs(A[i]) for i in range(NN)]

if count == 0:
    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    if det == 1:#全て同符号
        m = min(B)

        M = sum(B) - 2 * m
        print(M)

        for i in range(NN):
            if m == B[i]:
                p = i
                break

        C = [A[i]//B[i] for i in range(NN)]

        C[p] *= -1

    else:#異符号が含まれる
        M = sum(B)
        print(M)
        C = [A[i]//B[i] for i in range(NN)]

    fp = -1 #firstplus
    fm = -1 #firstminus
    for i in range(NN):
        if fp == -1 and C[i] == 1:
            fp = i
        elif fm == -1 and C[i] == -1:
            fm = i
        elif fp != -1 and fm != -1:
            break

    X = []
    Y = []

    for i in range(NN):
        if i == fp or i == fm:
            continue
        if C[i] == -1:
            X.append(i)
        else:
            Y.append(i)

    x = A[fp]
    for i in X:
        print(x,A[i])
        x -= A[i]

    y = A[fm]
    for i in Y:
        print(y,A[i])
        y -= A[i]

    print(x,y)

elif A == []:
    print(0)
    for i in range(count-1):
        print(0,0)

else:

    det = 1
    s = A[0]//B[0]#最初のやつの符号
    for i in range(1,NN):
        if s * A[i] < 0:
            det = -1
            break

    M = sum(B)
    print(M)

    if det == 1:#全て同符号
        #これがまずい
        if s < 0:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN):
                print(x,A[i])
                x -= A[i]
        else:
            for i in range(count-1):
                print(0,0)
            x = 0
            for i in range(NN-1):
                print(x,A[i])
                x -= A[i]
            print(A[NN-1],x)
            




    else:#異符号が含まれる
        #こちらは今まで通り処理して最後に0を引きまくれば良い
        
        C = [A[i]//B[i] for i in range(NN)]

        fp = -1 #firstplus
        fm = -1 #firstminus
        for i in range(NN):
            if fp == -1 and C[i] == 1:
                fp = i
            elif fm == -1 and C[i] == -1:
                fm = i
            elif fp != -1 and fm != -1:
               break

        X = []
        Y = []

        for i in range(NN):
            if i == fp or i == fm:
                continue
            if C[i] == -1:
                X.append(i)
            else:
                Y.append(i)

        x = A[fp]
        for i in X:
            print(x,A[i])
            x -= A[i]

        y = A[fm]
        for i in Y:
            print(y,A[i])
            y -= A[i]

        print(x,y)

        for i in range(count):
            print(x-y,0)