def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1])

if __name__ == "__main__":
    solve() def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1]) solve 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 = list(sorted(a)) a list(sorted(a)) list sorted(a) sorted a min_a = a.pop(0) min_a a.pop(0) a.pop a pop 0 max_a = a.pop(-1) max_a a.pop(-1) a.pop a pop -1 pos_a = filter(lambda x: x >= 0, a) pos_a filter(lambda x: x >= 0, a) filter lambda x: x >= 0 x >= 0 x 0 x a neg_a = filter(lambda x: x < 0, a) neg_a filter(lambda x: x < 0, a) filter lambda x: x < 0 x < 0 x 0 x a procedure = [] procedure [] state = min_a state min_a for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

     _a pos_a procedure.append((state, _a)) procedure.append procedure append (state, _a) state _a state -= _a state _a procedure.append((max_a, state)) procedure.append procedure append (max_a, state) max_a state state = max_a - state state max_a - state max_a state for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

     _a neg_a procedure.append((state, _a)) procedure.append procedure append (state, _a) state _a state -= _a state _a print(state) print state for t in procedure:
        print(t[0], t[1]) t procedure print(t[0], t[1]) print t[0] t 0 t[1] t 1 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1]) def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1]) solve
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1])

if __name__ == "__main__":
    solve()