/QUACAU - Qua cầu

<Problem>

http://ntucoder.net/Problem/Details/3307
              Uses Crt,Math;
      Var n,i,j,tg:longint; a,f:array[-100..10000] of int64;
      Begin
          readln(n);
          for i:=1 to n do read(a[i]);
          for i:=1 to n-1 do
           for j:=i to n do
            if a[i]>a[j] then begin tg:=a[i]; a[i]:=a[j]; a[j]:=tg; end;
      
          f[1]:=a[1];
          f[2]:=a[2]; //-> Truong hop 1 hoac 2
      
          for i:=3 to n do  //-> truong hop so nguoi lon hon 3
           begin
               f[i]:=min(f[i-1]+a[1]+a[i],f[i-2]+a[1]+a[i]+a[2]+a[2]);
               //writeln(f[i]);
           end;
          writeln(f[n]);
          readln;
      End.