program fruit;
var
n,energy:integer;
a,b:array[1..10000]of integer;
procedure ini;
var
i:integer;
begin
assign(input,'fruit.in');
reset(input);
assign(output,'fruit.out');
rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
close(input);
energy:=0;
end;
procedure order;
var
i,j,temp:integer;
begin
for i:=1 to n do
for j:=i+1 to n do
begin
if a[i]>a[j] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;{then}
end;{for j}
end;{order}
procedure main;
var
i:integer;
begin
for i:=2 to n do
a[i]:=a[i]+a[i-1];
for i:=2 to n do energy:=energy+a[i];
end;
procedure print;
begin
write(energy);
close(output);
end;
begin
ini;
order;
main;
print;
end.