N, *A = map(int, open(0).read().split())

x = sorted([v for v in A if v >= 0])
y = sorted([v for v in A if v < 0], reverse=True)

ans = []
if len(y) == 0:
    cnt = x[0]
    for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((x[-1], cnt))
    print(x[-1] - cnt)
elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    for v in x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
        
    cnt = x[-1]
    for v in y:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
    
for v in ans:
    print(*v) N, *A = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split *A A v for v in A if v >= 0 for v in A if v >= 0 v A v >= 0 v 0 if v >= 0 v x = sorted([v for v in A if v >= 0]) x sorted([v for v in A if v >= 0]) sorted [v for v in A if v >= 0] v for v in A if v < 0 for v in A if v < 0 v A v < 0 v 0 if v < 0 v y = sorted([v for v in A if v < 0], reverse=True) y sorted([v for v in A if v < 0], reverse=True) sorted [v for v in A if v < 0] reverse=True reverse True ans = [] ans [] if len(y) == 0:
    cnt = x[0]
    for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((x[-1], cnt))
    print(x[-1] - cnt)
elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    for v in x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
        
    cnt = x[-1]
    for v in y:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
     len(y) == 0 len(y) len y 0 cnt = x[0] cnt x[0] x 0 for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
     v x[1:-1] x 1:-1 1 -1 ans.append((cnt, v)) ans.append ans append (cnt, v) cnt v cnt -= v cnt v ans.append((x[-1], cnt)) ans.append ans append (x[-1], cnt) x[-1] x -1 cnt print(x[-1] - cnt) print x[-1] - cnt x[-1] x -1 cnt elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt) len(x) == 0 len(x) len x 0 cnt = y[0] cnt y[0] y 0 for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
     v y[1:] y 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 x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
        
     v x[:-1] x :-1 -1 ans.append((y[0], v)) ans.append ans append (y[0], v) y[0] y 0 v y[0] -= v y[0] y 0 v cnt = x[-1] cnt x[-1] x -1 for v in y:
        ans.append((cnt, v))
        cnt -= v
     v y 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 cnt = y[0] y[0] cnt cnt -= v v cnt cnt -= v v cnt N, *A = map(int, open(0).read().split()) map(int, open(0).read().split()) N x = sorted([v for v in A if v >= 0]) sorted([v for v in A if v >= 0]) x y = sorted([v for v in A if v < 0], reverse=True) sorted([v for v in A if v < 0], reverse=True) y ans = [] [] ans cnt = x[0] x[0] cnt cnt = x[-1] x[-1] cnt cnt -= v v cnt
N, *A = map(int, open(0).read().split())

x = sorted([v for v in A if v >= 0])
y = sorted([v for v in A if v < 0], reverse=True)

ans = []
if len(y) == 0:
    cnt = x[0]
    for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((x[-1], cnt))
    print(x[-1] - cnt)
elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    for v in x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
        
    cnt = x[-1]
    for v in y:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
    
for v in ans:
    print(*v)