const fi='chiakeo.inp'; fo='chiakeo.out';
nmax=100;
var a,b:array[1..nmax] of integer;
chk:array[0..20000] of boolean;
luu:array[1..20000] of byte;
tong:integer;
f:text;
n:byte;
 
procedure readf;
var k:byte;
begin
assign(f,fi); reset(f);
readln(f,n);
for k:=1 to n do read(f,a[k]);
close(f);
for k:=1 to n do b[k]:=a[k];
end;
 
procedure truy(i:integer);
begin
if i<>0 then
begin
truy(i-a[luu[i]]);
 
a[luu[i]]:=-1;
end;
end;
 
procedure xuly;
var k:byte;
i,mid:integer;
begin
tong:=0;
fillchar(chk,sizeof(chk),false);
chk[0]:=true;
for k:=1 to n do
begin
for i:=tong downto 0 do
if chk[i] then
if not chk[i+a[k]] then
begin
chk[i+a[k]]:=true;
luu[i+a[k]]:=k;
end;
inc(tong,a[k]);
end;
mid:=tong div 2;
while not chk[mid] do dec(mid);
assign(f,fo); rewrite(f);
writeln(f,tong-2*mid);
truy(mid);
writeln(f);
for k:=1 to n do
if a[k]>=0 then write(f,a[k],' ');
writeln(f);
for k:=1 to n do if a[k]<0 then write(f,b[k],' ');
 
close(f);
end;
 
begin
readf;
xuly;
end.