program fruit;
var sum,s,k,n:longint;
a:array[0..10001] of longint;
procedure qsort(l,r:longint);
var i,j,m,p:longint;
begin
i:=l;
j:=r;
m:=a[(l+r)div 2];
repeat
while a[i]<m do inc(i);
while a[j]>m do dec(j);
if i<=j then
begin
p:=a[i];
a[i]:=a[j];
a[j]:=p;
inc(i);
dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end;
procedure insert(x,y:longint);
var i,j:longint; f:boolean;
begin
for i:=x to y-1 do
begin
if a[i]>a[i+1] then begin j:=a[i];a[i]:=a[i+1];a[i+1]:=j; end;
end;
end;
begin
assign(input,'fruit.in');
assign(output,'fruit.out');
reset(input);
rewrite(output);
readln(n);
for k:=1 to n do
read(a[k]);
qsort(1,n);
for k:=1 to n-1 do
begin
a[k+1]:=a[k]+a[k+1];
a[k]:=0;
s:=a[k+1];
sum:=sum+s;
insert(K+1,n);
end;
writeln(sum);
close(input);
close(output);
end.