program fruit;
type
fxz=array[0..10000]of longint;
var
a:fxz;
step,i,m,n,l:longint;
f1,f2:text;
procedure qsort(p,q:longint);
var
i,j,c:longint;
begin
if p<q then begin
i:=p;
for j := p+1 to q do begin
if a[j]<a[p] then begin
inc(i);
c:=a[i];a[i]:=a[j];a[j]:=c;
end;
end;
c:=a[i];a[i]:=a[p];a[p]:=c;
qsort(p,i-1);
qsort(i+1,q);
end;
end;
procedure work;
var
i,j:longint;
begin
if n=1 then step:=step+a[1]
else begin
m:=a[1]+a[2];step:=step+m;
for i:=1 to n-2 do a[i]:=a[i+2];
if (a[1]<m)and(a[n-2]>m)then begin
for i:=2 to n-2 do
if ((a[i-1]<=m)and(a[i]>m))or((a[i-1]<m)and(a[i]>=m)) then
begin for j:=n-1 downto i+1 do a[j]:=a[j-1];
a[i]:=m;n:=n-1;
end;
end
else if a[1]>=m then begin for j:=n-1 downto 2 do
a[j]:=a[j-1];
a[1]:=m;
n:=n-1;
end
else begin a[n-1]:=m;n:=n-1;end;
end;
end;
begin
assign(f1,'fruit.in');
assign(f2,'fruit.out');
reset(f1);rewrite(f2);
readln(f1,l);
for i:=1 to l do
read(f1,a[i]);
qsort(1,l);
n:=l;
for i:=1 to l-1 do
work;
writeln(f2,step);
close(f1);close(f2);
end.