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

leftest_val = A[0]
rightest_val = A[-1]
left_idx = 1
right_idx = N - 2
history = []
for i in range(N - 1):
    left_val = A[left_idx]
    right_val = A[right_idx]
    if i == N - 2:
        history.append("{} {}".format(rightest_val, leftest_val))
        print(rightest_val - leftest_val)
    elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
    else:
        history.append("{} {}".format(leftest_val, right_val))
        leftest_val -= right_val
        right_idx -= 1

for h in history:
    print(h) 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 A = sorted(A) A sorted(A) sorted A leftest_val = A[0] leftest_val A[0] A 0 rightest_val = A[-1] rightest_val A[-1] A -1 left_idx = 1 left_idx 1 right_idx = N - 2 right_idx N - 2 N 2 history = [] history [] for i in range(N - 1):
    left_val = A[left_idx]
    right_val = A[right_idx]
    if i == N - 2:
        history.append("{} {}".format(rightest_val, leftest_val))
        print(rightest_val - leftest_val)
    elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
    else:
        history.append("{} {}".format(leftest_val, right_val))
        leftest_val -= right_val
        right_idx -= 1 i range(N - 1) range N - 1 N 1 left_val = A[left_idx] left_val A[left_idx] A left_idx right_val = A[right_idx] right_val A[right_idx] A right_idx if i == N - 2:
        history.append("{} {}".format(rightest_val, leftest_val))
        print(rightest_val - leftest_val)
    elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
    else:
        history.append("{} {}".format(leftest_val, right_val))
        leftest_val -= right_val
        right_idx -= 1 i == N - 2 i N - 2 N 2 history.append("{} {}".format(rightest_val, leftest_val)) history.append history append "{} {}".format(rightest_val, leftest_val) "{} {}".format "{} {}" format rightest_val leftest_val print(rightest_val - leftest_val) print rightest_val - leftest_val rightest_val leftest_val elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
     left_val < 0 left_val 0 history.append("{} {}".format(rightest_val, left_val)) history.append history append "{} {}".format(rightest_val, left_val) "{} {}".format "{} {}" format rightest_val left_val rightest_val -= left_val rightest_val left_val left_idx += 1 left_idx 1 history.append("{} {}".format(leftest_val, right_val)) history.append history append "{} {}".format(leftest_val, right_val) "{} {}".format "{} {}" format leftest_val right_val leftest_val -= right_val leftest_val right_val right_idx -= 1 right_idx 1 for h in history:
    print(h) h history print(h) print h history = [] [] history leftest_val -= right_val right_val leftest_val rightest_val -= left_val left_val rightest_val right_val = A[right_idx] A[right_idx] right_val right_idx -= 1 1 right_idx rightest_val = A[-1] A[-1] rightest_val right_idx = N - 2 N - 2 right_idx left_idx = 1 1 left_idx N = int(input()) int(input()) N left_idx += 1 1 left_idx A = list(map(int, input().split())) list(map(int, input().split())) A leftest_val = A[0] A[0] leftest_val A = sorted(A) sorted(A) A left_val = A[left_idx] A[left_idx] left_val
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

leftest_val = A[0]
rightest_val = A[-1]
left_idx = 1
right_idx = N - 2
history = []
for i in range(N - 1):
    left_val = A[left_idx]
    right_val = A[right_idx]
    if i == N - 2:
        history.append("{} {}".format(rightest_val, leftest_val))
        print(rightest_val - leftest_val)
    elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
    else:
        history.append("{} {}".format(leftest_val, right_val))
        leftest_val -= right_val
        right_idx -= 1

for h in history:
    print(h)