#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut a = get!([isize]);

    let mut minus = Vec::new();
    let mut plus = Vec::new();
    let mut zflag = false;
    for &e in &a {
        if e < 0 {
            minus.push(e);
        } else if e == 0 {
            zflag = true;
            plus.push(e);
        } else {
            plus.push(e);
        }
    }

    if plus.len() == 0 {
        minus.sort();
        let mut now = minus.pop().unwrap();
        println!("{}", now - minus.iter().sum::<isize>());
        for e in minus.into_iter().rev() {
            println!("{} {}", now, e);
            now -= e;
        }
        return;
    } else if minus.len() == 0 {
        if zflag {
            plus.sort();
            println!("{}", plus.iter().sum::<isize>());
            let last = plus.pop().unwrap();
            plus.remove(0);
            let mut now = 0;
            for e in plus.into_iter() {
                println!("{} {}", now, e);
                now -= e;
            }
            println!("{} {}", last, now);
            return;
        }
            
        plus.sort();
        println!("{}", plus.iter().skip(1).sum::<isize>()-plus[0]);
        let mut now = plus.remove(0);
        let last = plus.remove(0);
        for e in plus {
            println!("{} {}", now, e);
            now -= e;
        }
        println!("{} {}", last, now);
        return;
    }

    println!("{}", plus.iter().sum::<isize>()-minus.iter().sum::<isize>());

    let mut now = minus.pop().unwrap();
    for &e in plus.iter().skip(1) {
        println!("{} {}", now, e);
        now -= e;
    }
    println!("{} {}", plus[0], now);
    now = plus[0]-now;
    for e in minus {
        println!("{} {}", now, e);
        now -= e;
    }
}


Measured memory_bytes: 14204