import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans))


if __name__ == "__main__":
    main() import sys sys from bisect import bisect_left input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans)) main 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.sort() A.sort A sort idx = bisect_left(A[1:-1], 0) idx bisect_left(A[1:-1], 0) bisect_left A[1:-1] A 1:-1 1 -1 0 m_group = A[1:1 + idx] m_group A[1:1 + idx] A 1:1 + idx 1 1 + idx 1 idx p_group = A[1 + idx: -1] p_group A[1 + idx: -1] A 1 + idx: -1 1 + idx 1 idx -1 ans = [] ans [] MAX = A[-1] MAX A[-1] A -1 for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

     m m_group ans.append(f"{MAX} {m}") ans.append ans append f"{MAX} {m}" MAX -= m MAX m MIN = A[0] MIN A[0] A 0 for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

     p p_group ans.append(f"{MIN} {p}") ans.append ans append f"{MIN} {p}" MIN -= p MIN p ans.append(f"{MAX} {MIN}") ans.append ans append f"{MAX} {MIN}" M = MAX - MIN M MAX - MIN MAX MIN print(M) print M print("\n".join(ans)) print "\n".join(ans) "\n".join "\n" join ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans)) def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans)) main input = sys.stdin.readline sys.stdin.readline input
import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    idx = bisect_left(A[1:-1], 0)
    m_group = A[1:1 + idx]
    p_group = A[1 + idx: -1]

    ans = []

    MAX = A[-1]
    for m in m_group:
        ans.append(f"{MAX} {m}")
        MAX -= m

    MIN = A[0]
    for p in p_group:
        ans.append(f"{MIN} {p}")
        MIN -= p

    ans.append(f"{MAX} {MIN}")
    M = MAX - MIN

    print(M)
    print("\n".join(ans))


if __name__ == "__main__":
    main()
