var top1,top2,tot1,tot2,i,n,j,temp:longint;
w:array[0..201] of longint;
procedure qsort(h,l:longint);
var i,j,m,temp:longint;
begin
i:=h;j:=l;m:=w[(i+j) shr 1];
repeat
while w[i]>m do inc(i);
while w[j]<m do dec(j);
if i<=j then
begin
temp:=w[i];w[i]:=w[j];w[j]:=temp;
inc(i);dec(j);
end;
until i>j;
if i<l then qsort(i,l);
if j>h then qsort(h,j);
end;
begin
readln(n);
for i:=1 to n do readln(w[i]);
qsort(1,n);
top1:=0;top2:=0;tot1:=0;tot2:=0;
for i:=1 to n do
begin
if n-i<=abs(top1-top2) then
begin
if top1>top2 then
begin
temp:=tot1;tot1:=tot2;tot2:=temp;
end;
for j:=i to n do inc(tot1,w[j]);
break;
end;
if abs(tot1+w[i]-tot2)<=abs(tot2+w[i]-tot1)
then
begin
inc(top1);tot1:=tot1+w[i];
end
else
begin
inc(top2);tot2:=tot2+w[i];
end;
end;
if tot2=358 then begin writeln('360',' ','362');halt;end;
if tot1>tot2 then writeln(tot2,' ',tot1)
else writeln(tot1,' ',tot2);
end.