# diverta2019-2C - Successive Subtraction
def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j)


if __name__ == "__main__":
    main() def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j) main n = int(input()) n int(input()) int input() input lst = sorted(map(int, input().rstrip().split())) lst sorted(map(int, input().rstrip().split())) sorted map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split s = lst[0] s lst[0] lst 0 l = lst[-1] l lst[-1] lst -1 log = [] log [] for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
     i lst[1:-1] lst 1:-1 1 -1 if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
     i > 0 i 0 log += [(s, i)] log [(s, i)] (s, i) s i s -= i s i log += [(l, i)] log [(l, i)] (l, i) l i l -= i l i log += [(l, s)] log [(l, s)] (l, s) l s print(l - s) print l - s l s for i, j in log:
        print(i, j) i j log print(i, j) print i j if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j) def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j) main
# diverta2019-2C - Successive Subtraction
def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j)


if __name__ == "__main__":
    main()