program bing;
var
f1,f2:text;
n:integer;
a:array[1..10000] of integer;
i,j,s,ss:integer;
procedure nb(x,y:integer);
var
i,j:integer;
temp1,temp2:integer;
begin
i:=x;j:=y;
temp1:=a[(x+y)shr 1];
repeat
while a[i]<temp1 do
i:=i+1;
while a[j]>temp1 do
j:=j-1;
if i<=j then
begin
temp2:=a[i];a[i]:=a[j];a[j]:=temp2;
i:=i+1;j:=j-1;
end;
until i>j;
if x<j then nb(x,j);
if y>i then nb(i,y);
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]);
nb(1,n);
s:=a[1];ss:=0;
for i:=2 to n do
begin
s:=s+a[i];
ss:=ss+s; end;
write(f2,ss);
close(f1);close(f2);
end.