N = int(input())
*A, = map(int, input().split())
INF = 10**9
p = q = 0
for i, a in enumerate(A):
    if a > 0:
        p += 1
    elif a < 0:
        q += 1

def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R
ans = 0
if p > 0 and q > 0:
    s = t = 0
    for a in A:
        if a > 0:
            t = a
        elif a < 0:
            s = a
    ans, R = solve(s, t)
elif p > 0:
    A.sort()
    ans, R = solve(A[0], A[1])
elif q > 0:
    A.sort()
    ans, R = solve(A[-2], A[-1])
else:
    R = ["0 0\n"]*(N-1)
print(ans)
print("".join(R)) N = int(input()) N int(input()) int input() input *A, = map(int, input().split()) *A A map(int, input().split()) map int input().split() ().split () input split INF = 10**9 INF 10**9 10 9 p = q = 0 p 0 = q = 0 q 0 for i, a in enumerate(A):
    if a > 0:
        p += 1
    elif a < 0:
        q += 1 i a enumerate(A) enumerate A if a > 0:
        p += 1
    elif a < 0:
        q += 1 a > 0 a 0 p += 1 p 1 elif a < 0:
        q += 1 a < 0 a 0 q += 1 q 1 def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R solve R = [] R [] i = A.index(s) i A.index(s) A.index A index s if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
     s == t s t j = A.index(t, i+1) j A.index(t, i+1) A.index A index t i+1 i 1 j = A.index(t) j A.index(t) A.index A index t for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
     k a enumerate(A) enumerate A if i == k or j == k:
            continue
         i == k or j == k i == k i k j == k j k continue if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
     a >= 0 a 0 R.append("%d %d\n" % (s, a)) R.append R append "%d %d\n" % (s, a) "%d %d\n" (s, a) s a s -= a s a for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
     k a enumerate(A) enumerate A if i == k or j == k:
            continue
         i == k or j == k i == k i k j == k j k continue if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
     a < 0 a 0 R.append("%d %d\n" % (t, a)) R.append R append "%d %d\n" % (t, a) "%d %d\n" (t, a) t a t -= a t a R.append("%d %d\n" % (t, s)) R.append R append "%d %d\n" % (t, s) "%d %d\n" (t, s) t s t -= s t s return t, R return t, R t R s s t t ans = 0 ans 0 if p > 0 and q > 0:
    s = t = 0
    for a in A:
        if a > 0:
            t = a
        elif a < 0:
            s = a
    ans, R = solve(s, t)
elif p > 0:
    A.sort()
    ans, R = solve(A[0], A[1])
elif q > 0:
    A.sort()
    ans, R = solve(A[-2], A[-1])
else:
    R = ["0 0\n"]*(N-1) p > 0 and q > 0 p > 0 p 0 q > 0 q 0 s = t = 0 s 0 = t = 0 t 0 for a in A:
        if a > 0:
            t = a
        elif a < 0:
            s = a
     a A if a > 0:
            t = a
        elif a < 0:
            s = a
     a > 0 a 0 t = a t a elif a < 0:
            s = a
     a < 0 a 0 s = a s a ans, R = solve(s, t) ans solve(s, t) solve s t R elif p > 0:
    A.sort()
    ans, R = solve(A[0], A[1]) p > 0 p 0 A.sort() A.sort A sort ans, R = solve(A[0], A[1]) ans solve(A[0], A[1]) solve A[0] A 0 A[1] A 1 R elif q > 0:
    A.sort()
    ans, R = solve(A[-2], A[-1]) q > 0 q 0 A.sort() A.sort A sort ans, R = solve(A[-2], A[-1]) ans solve(A[-2], A[-1]) solve A[-2] A -2 A[-1] A -1 R R = ["0 0\n"]*(N-1) R ["0 0\n"]*(N-1) ["0 0\n"] "0 0\n" N-1 N 1 print(ans) print ans print("".join(R)) print "".join(R) "".join "" join R N = int(input()) int(input()) N q += 1 1 q R = ["0 0\n"]*(N-1) ["0 0\n"]*(N-1) R q = 0 0 q p = q = 0 0 p ans = 0 0 ans t = a a t ans, R = solve(A[-2], A[-1]) solve(A[-2], A[-1]) ans def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R solve s = t = 0 0 s INF = 10**9 10**9 INF R = solve(s, t) solve(s, t) R R = solve(A[0], A[1]) solve(A[0], A[1]) R R = solve(A[-2], A[-1]) solve(A[-2], A[-1]) R t = 0 0 t ans, R = solve(s, t) solve(s, t) ans ans, R = solve(A[0], A[1]) solve(A[0], A[1]) ans s = a a s p += 1 1 p
N = int(input())
*A, = map(int, input().split())
INF = 10**9
p = q = 0
for i, a in enumerate(A):
    if a > 0:
        p += 1
    elif a < 0:
        q += 1

def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R
ans = 0
if p > 0 and q > 0:
    s = t = 0
    for a in A:
        if a > 0:
            t = a
        elif a < 0:
            s = a
    ans, R = solve(s, t)
elif p > 0:
    A.sort()
    ans, R = solve(A[0], A[1])
elif q > 0:
    A.sort()
    ans, R = solve(A[-2], A[-1])
else:
    R = ["0 0\n"]*(N-1)
print(ans)
print("".join(R))