n = int(input())
a = list(map(int, input().split()))
cnt_m = len(list(filter(lambda x: x < 0, a)))

if cnt_m == 0:
    i_m = a.index(min(a))
    i_p = (i_m + 1) % n
elif cnt_m == n:
    i_p = a.index(max(a))
    i_m = (i_p + 1) % n
else:
    i_m = i_p = -1
    for i in range(n):
        if i_m == -1 and a[i] < 0:
            i_m = i
        if i_p == -1 and a[i] >= 0:
            i_p = i

is_used = [False] * n
ans = []

is_used[i_m] = True
is_used[i_p] = True
s_m = a[i_m]
s_p = a[i_p]
for i in range(n):
    if not is_used[i]:
        if a[i] >= 0:
            ans.append((s_m, a[i]))
            s_m -= a[i]
        else:
            ans.append((s_p, a[i]))
            s_p -= a[i]

        is_used[i] = True

ans.append((s_p, s_m))
ans_s = s_p - s_m

print(ans_s)
for ans_i in ans:
    print(*ans_i) n = int(input()) n int(input()) int input() input a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt_m = len(list(filter(lambda x: x < 0, a))) cnt_m len(list(filter(lambda x: x < 0, a))) len list(filter(lambda x: x < 0, a)) list filter(lambda x: x < 0, a) filter lambda x: x < 0 x < 0 x 0 x a if cnt_m == 0:
    i_m = a.index(min(a))
    i_p = (i_m + 1) % n
elif cnt_m == n:
    i_p = a.index(max(a))
    i_m = (i_p + 1) % n
else:
    i_m = i_p = -1
    for i in range(n):
        if i_m == -1 and a[i] < 0:
            i_m = i
        if i_p == -1 and a[i] >= 0:
            i_p = i cnt_m == 0 cnt_m 0 i_m = a.index(min(a)) i_m a.index(min(a)) a.index a index min(a) min a i_p = (i_m + 1) % n i_p (i_m + 1) % n i_m + 1 i_m 1 n elif cnt_m == n:
    i_p = a.index(max(a))
    i_m = (i_p + 1) % n cnt_m == n cnt_m n i_p = a.index(max(a)) i_p a.index(max(a)) a.index a index max(a) max a i_m = (i_p + 1) % n i_m (i_p + 1) % n i_p + 1 i_p 1 n i_m = i_p = -1 i_m -1 = i_p = -1 i_p -1 for i in range(n):
        if i_m == -1 and a[i] < 0:
            i_m = i
        if i_p == -1 and a[i] >= 0:
            i_p = i i range(n) range n if i_m == -1 and a[i] < 0:
            i_m = i
         i_m == -1 and a[i] < 0 i_m == -1 i_m -1 a[i] < 0 a[i] a i 0 i_m = i i_m i if i_p == -1 and a[i] >= 0:
            i_p = i i_p == -1 and a[i] >= 0 i_p == -1 i_p -1 a[i] >= 0 a[i] a i 0 i_p = i i_p i is_used = [False] * n is_used [False] * n [False] False n ans = [] ans [] is_used[i_m] = True is_used[i_m] is_used i_m True is_used[i_p] = True is_used[i_p] is_used i_p True s_m = a[i_m] s_m a[i_m] a i_m s_p = a[i_p] s_p a[i_p] a i_p for i in range(n):
    if not is_used[i]:
        if a[i] >= 0:
            ans.append((s_m, a[i]))
            s_m -= a[i]
        else:
            ans.append((s_p, a[i]))
            s_p -= a[i]

        is_used[i] = True i range(n) range n if not is_used[i]:
        if a[i] >= 0:
            ans.append((s_m, a[i]))
            s_m -= a[i]
        else:
            ans.append((s_p, a[i]))
            s_p -= a[i]

        is_used[i] = True not is_used[i] is_used[i] is_used i if a[i] >= 0:
            ans.append((s_m, a[i]))
            s_m -= a[i]
        else:
            ans.append((s_p, a[i]))
            s_p -= a[i]

         a[i] >= 0 a[i] a i 0 ans.append((s_m, a[i])) ans.append ans append (s_m, a[i]) s_m a[i] a i s_m -= a[i] s_m a[i] a i ans.append((s_p, a[i])) ans.append ans append (s_p, a[i]) s_p a[i] a i s_p -= a[i] s_p a[i] a i is_used[i] = True is_used[i] is_used i True ans.append((s_p, s_m)) ans.append ans append (s_p, s_m) s_p s_m ans_s = s_p - s_m ans_s s_p - s_m s_p s_m print(ans_s) print ans_s for ans_i in ans:
    print(*ans_i) ans_i ans print(*ans_i) print *ans_i ans_i ans = [] [] ans i_p = (i_m + 1) % n (i_m + 1) % n i_p s_p = a[i_p] a[i_p] s_p i_p = -1 -1 i_p i_m = i_p = -1 -1 i_m i_p = i i i_p cnt_m = len(list(filter(lambda x: x < 0, a))) len(list(filter(lambda x: x < 0, a))) cnt_m i_m = i i i_m is_used = [False] * n [False] * n is_used s_p -= a[i] a[i] s_p n = int(input()) int(input()) n i_m = (i_p + 1) % n (i_p + 1) % n i_m i_p = a.index(max(a)) a.index(max(a)) i_p a = list(map(int, input().split())) list(map(int, input().split())) a s_m -= a[i] a[i] s_m s_m = a[i_m] a[i_m] s_m i_m = a.index(min(a)) a.index(min(a)) i_m ans_s = s_p - s_m s_p - s_m ans_s
n = int(input())
a = list(map(int, input().split()))
cnt_m = len(list(filter(lambda x: x < 0, a)))

if cnt_m == 0:
    i_m = a.index(min(a))
    i_p = (i_m + 1) % n
elif cnt_m == n:
    i_p = a.index(max(a))
    i_m = (i_p + 1) % n
else:
    i_m = i_p = -1
    for i in range(n):
        if i_m == -1 and a[i] < 0:
            i_m = i
        if i_p == -1 and a[i] >= 0:
            i_p = i

is_used = [False] * n
ans = []

is_used[i_m] = True
is_used[i_p] = True
s_m = a[i_m]
s_p = a[i_p]
for i in range(n):
    if not is_used[i]:
        if a[i] >= 0:
            ans.append((s_m, a[i]))
            s_m -= a[i]
        else:
            ans.append((s_p, a[i]))
            s_p -= a[i]

        is_used[i] = True

ans.append((s_p, s_m))
ans_s = s_p - s_m

print(ans_s)
for ans_i in ans:
    print(*ans_i)
