def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row)


if __name__ == '__main__':
    main() def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row) main from bisect import bisect_left 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 a.sort() a.sort a sort i0 = bisect_left(a, 0) i0 bisect_left(a, 0) bisect_left a 0 sum_ = 0 sum_ 0 if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

     i0 == 0 i0 0 ret = [] ret [] s = a[0] s a[0] a 0 e = a[-1] e a[-1] a -1 for x in a[1:-1]:
            ret.append((s, x))
            s -= x
         x a[1:-1] a 1:-1 1 -1 ret.append((s, x)) ret.append ret append (s, x) s x s -= x s x ret.append((e, s)) ret.append ret append (e, s) e s e -= s e s sum_ = e sum_ e elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

     i0 == n i0 n ret = [] ret [] s = a[-1] s a[-1] a -1 for x in a[:-1]:
            ret.append((s, x))
            s -= x
         x a[:-1] a :-1 -1 ret.append((s, x)) ret.append ret append (s, x) s x s -= x s x sum_ = s sum_ s ret = [] ret [] m = a[0] m a[0] a 0 for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

         x a[i0:-1] a i0:-1 i0 -1 ret.append((m, x)) ret.append ret append (m, x) m x m -= x m x p = a[-1] p a[-1] a -1 for x in a[1:i0]:
            ret.append((p, x))
            p -= x

         x a[1:i0] a 1:i0 1 i0 ret.append((p, x)) ret.append ret append (p, x) p x p -= x p x ret.append((p, m)) ret.append ret append (p, m) p m sum_ = p - m sum_ p - m p m print(sum_) print sum_ for row in ret:
        print(*row) row ret print(*row) print *row row if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row) def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row) main
def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row)


if __name__ == '__main__':
    main()
