unittest
{
	assert( [ "3", "1 -1 2" ].parse.expand.solve == "4\n-1 1\n2 -2" );
	assert( [ "3", "1 1 1" ].parse.expand.solve == "1\n1 1\n1 0" );
	
	assert( [ "5", "-2 -1 0 1 2" ].parse.expand.solve == "6\n-2 1\n2 -3\n5 -1\n6 0" );		// 追加ケース
	assert( [ "3", "-1 -1 -1" ].parse.expand.solve == "1\n-1 -1\n0 -1" );		// 追加ケース
	assert( [ "3", "-3 -2 -1" ].parse.expand.solve == "4\n-1 -3\n2 -2" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	auto anss = new string[ as.length - 1 ];
	auto ansi = 0L;
	auto ansm = as.back;
	as.popBack;
	
	// 一番大きい値以外のプラス値を一番小さい値に突っ込む
	while( !as.empty && 0 < as.back )
	{
		anss[ ansi ] = format( "%s %s", as.front, as.back );
		ansi++;
		as.front -= as.back;
		as.popBack;
	}
	
	// マイナス値を一番大きい値に突っ込む
	while( !as.empty )
	{
		anss[ ansi ] = format( "%s %s", ansm, as.front );
		ansi++;
		ansm -= as.front;
		as.popFront;
	}
	
	return format( "%s\n%s", ansm, anss.join( "\n" ) );
}
