
N = int(input())
X = list(map(int, input().split()))

pos = sorted([v for v in X if v >= 0])
neg = sorted([v for v in X if v < 0], reverse=True)

ans = []
if not neg:
    # neg is empty
    cnt = pos[0]
    for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((pos[-1], cnt))
    print(pos[-1] - cnt)
elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    # neg and pos exist
    for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v

    cnt = pos[-1]
    for v in neg:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)

for v in ans:
    print(*v) N = int(input()) N int(input()) int input() input X = list(map(int, input().split())) X list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v for v in X if v >= 0 for v in X if v >= 0 v X v >= 0 v 0 if v >= 0 v pos = sorted([v for v in X if v >= 0]) pos sorted([v for v in X if v >= 0]) sorted [v for v in X if v >= 0] v for v in X if v < 0 for v in X if v < 0 v X v < 0 v 0 if v < 0 v neg = sorted([v for v in X if v < 0], reverse=True) neg sorted([v for v in X if v < 0], reverse=True) sorted [v for v in X if v < 0] reverse=True reverse True ans = [] ans [] if not neg:
    # neg is empty
    cnt = pos[0]
    for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((pos[-1], cnt))
    print(pos[-1] - cnt)
elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    # neg and pos exist
    for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v

    cnt = pos[-1]
    for v in neg:
        ans.append((cnt, v))
        cnt -= v
    print(cnt) not neg neg cnt = pos[0] cnt pos[0] pos 0 for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
     v pos[1:-1] pos 1:-1 1 -1 ans.append((cnt, v)) ans.append ans append (cnt, v) cnt v cnt -= v cnt v ans.append((pos[-1], cnt)) ans.append ans append (pos[-1], cnt) pos[-1] pos -1 cnt print(pos[-1] - cnt) print pos[-1] - cnt pos[-1] pos -1 cnt elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt) not pos pos cnt = neg[0] cnt neg[0] neg 0 for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
     v neg[1:] neg 1: 1 ans.append((cnt, v)) ans.append ans append (cnt, v) cnt v cnt -= v cnt v print(cnt) print cnt for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v

     v pos[:-1] pos :-1 -1 ans.append((neg[0], v)) ans.append ans append (neg[0], v) neg[0] neg 0 v neg[0] -= v neg[0] neg 0 v cnt = pos[-1] cnt pos[-1] pos -1 for v in neg:
        ans.append((cnt, v))
        cnt -= v
     v neg ans.append((cnt, v)) ans.append ans append (cnt, v) cnt v cnt -= v cnt v print(cnt) print cnt for v in ans:
    print(*v) v ans print(*v) print *v v ans = [] [] ans neg = sorted([v for v in X if v < 0], reverse=True) sorted([v for v in X if v < 0], reverse=True) neg cnt = pos[-1] pos[-1] cnt N = int(input()) int(input()) N pos = sorted([v for v in X if v >= 0]) sorted([v for v in X if v >= 0]) pos cnt = pos[0] pos[0] cnt cnt = neg[0] neg[0] cnt X = list(map(int, input().split())) list(map(int, input().split())) X cnt -= v v cnt cnt -= v v cnt cnt -= v v cnt

N = int(input())
X = list(map(int, input().split()))

pos = sorted([v for v in X if v >= 0])
neg = sorted([v for v in X if v < 0], reverse=True)

ans = []
if not neg:
    # neg is empty
    cnt = pos[0]
    for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((pos[-1], cnt))
    print(pos[-1] - cnt)
elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    # neg and pos exist
    for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v

    cnt = pos[-1]
    for v in neg:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)

for v in ans:
    print(*v)
