program fruit;
var
a:array[1..10000]of integer;
n,x,i,j,k:integer;
f1,f2:text;
procedure qp(left,right:integer);
var
l,r,x,y:integer;
begin
l:=left;r:=right;
x:=a[(l+r)div 2];
repeat
while a[l]<x do inc(l);
while a[r]>x do dec(r);
if l<=r then
begin
y:=a[l];
a[l]:=a[r];
a[r]:=y;
inc(l);
dec(r);
end;
until l>r;
if (l<right)then qp(l,right);
if (r>left)then qp(left,r);
end;
begin
assign(f1,'fruit.in');reset(f1);
assign(f2,'fruit.out');rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
qp(1,n);
k:=0;
for i:=1 to n-1 do begin
k:=k+a[i]+a[i+1];
a[i+1]:=a[i+1]+a[i];
end;
write(f2,k);
close(f1);
close(f2);
end.