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

p,m = [],[]
p_total = 0
m_total = 0
p_max,p_min = 0,10**10
m_max,m_min = -10**10,0
p_count,p_min_idx,p_max_idx = 0,0,0
m_count,m_min_idx,m_max_idx = 0,0,0
for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1

if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i] 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 p,m = [],[] p [] m [] p_total = 0 p_total 0 m_total = 0 m_total 0 p_max,p_min = 0,10**10 p_max 0 p_min 10**10 10 10 m_max,m_min = -10**10,0 m_max -10**10 -10 10 m_min 0 p_count,p_min_idx,p_max_idx = 0,0,0 p_count 0 p_min_idx 0 p_max_idx 0 m_count,m_min_idx,m_max_idx = 0,0,0 m_count 0 m_min_idx 0 m_max_idx 0 for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1 a A if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1 a < 0 a 0 if m_min > a:
            m_min = a
            m_min_idx = m_count
         m_min > a m_min a m_min = a m_min a m_min_idx = m_count m_min_idx m_count if m_max < a:
            m_max = a
            m_max_idx = m_count
         m_max < a m_max a m_max = a m_max a m_max_idx = m_count m_max_idx m_count m_total += a m_total a m.append(a) m.append m append a m_count += 1 m_count 1 if p_min > a:
            p_min = a
            p_min_idx = p_count
         p_min > a p_min a p_min = a p_min a p_min_idx = p_count p_min_idx p_count if p_max < a:
            p_max = a
            p_max_idx = p_count
         p_max < a p_max a p_max = a p_max a p_max_idx = p_count p_max_idx p_count p_total += a p_total a p.append(a) p.append p append a p_count += 1 p_count 1 if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i] len(m) == 0 len(m) len m 0 print(p_total-2*p_min) print p_total-2*p_min p_total 2*p_min 2 p_min for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
     i range(len(p)-1) range len(p)-1 len(p) len p 1 if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
     i != p_min_idx i p_min_idx print(p[p_min_idx],p[i]) print p[p_min_idx] p p_min_idx p[i] p i p[p_min_idx] -= p[i] p[p_min_idx] p p_min_idx p[i] p i print(p[-1],p[p_min_idx]) print p[-1] p -1 p[p_min_idx] p p_min_idx elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1]) len(p) == 0 len(p) len p 0 print(2*m_max-m_total) print 2*m_max-m_total 2*m_max 2 m_max m_total for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
     i range(len(m)-1) range len(m)-1 len(m) len m 1 if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
     i != m_max_idx i m_max_idx print(m[m_max_idx],m[i]) print m[m_max_idx] m m_max_idx m[i] m i m[m_max_idx] -= m[i] m[m_max_idx] m m_max_idx m[i] m i print(m[m_max_idx],m[-1]) print m[m_max_idx] m m_max_idx m[-1] m -1 print(p_total-m_total) print p_total-m_total p_total m_total for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
     i v enumerate(p) enumerate p if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
     i != p_max_idx i p_max_idx print(m[0], v) print m[0] m 0 v m[0] -= v m[0] m 0 v for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i] i range(len(m)) range len(m) len m print(p[p_max_idx],m[i]) print p[p_max_idx] p p_max_idx m[i] m i p[p_max_idx] -= m[i] p[p_max_idx] p p_max_idx m[i] m i m_total += a a m_total p_count,p_min_idx,p_max_idx = 0,0,0 0 p_count p_total += a a p_total p_min = 0,10**10 10**10 p_min m_max_idx = 0,0,0 0 m_max_idx p_max_idx = 0,0,0 0 p_max_idx p_min_idx = p_count p_count p_min_idx p_max = a a p_max p_count += 1 1 p_count p_min = a a p_min p_max_idx = p_count p_count p_max_idx p_total = 0 0 p_total m_max,m_min = -10**10,0 -10**10 m_max A = list(map(int,input().split())) list(map(int,input().split())) A p,m = [],[] [] p p_max,p_min = 0,10**10 0 p_max m_total = 0 0 m_total m_min = a a m_min m_max_idx = m_count m_count m_max_idx m_min = -10**10,0 0 m_min m_max = a a m_max N = int(input()) int(input()) N m_min_idx,m_max_idx = 0,0,0 0 m_min_idx m_count,m_min_idx,m_max_idx = 0,0,0 0 m_count m_count += 1 1 m_count p_min_idx,p_max_idx = 0,0,0 0 p_min_idx m = [],[] [] m m_min_idx = m_count m_count m_min_idx
N = int(input())
A = list(map(int,input().split()))

p,m = [],[]
p_total = 0
m_total = 0
p_max,p_min = 0,10**10
m_max,m_min = -10**10,0
p_count,p_min_idx,p_max_idx = 0,0,0
m_count,m_min_idx,m_max_idx = 0,0,0
for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1

if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]