Program tz;
Var
n,k,i,s:longint;f1,f2:text;
a:array [1..10000] of longint;
procedure Tsort(q:integer);
Var
temp:array [1..20000] of boolean;
i,j:integer;
begin
k:=0;
fillchar(temp,sizeof(temp),false);
For i:=1 to q do
temp[a[i]]:=true;
fillchar(a,sizeof(a),0);
For i:=1 to 10000 do
if temp[i] then
Begin
inc(k);
a[k]:=i;
End;
End;
Begin
assign(f1,'fruit.in');
assign(f2,'fruit.out');
reset(f1);rewrite(f2);
readln(f1,n);
For i:=1 to n do read(f1,a[i]);
tsort(n);
s:=a[1];
for i:=2 to n do
begin
if s=a[1] then s:=s+a[i] else
s:=s+s+a[i];
end;
writeln(f2,s);
close(f1);close(f2);
End.