{$A+,B-,D+,E-,F-,G-,I-,L+,N+,O-,P-,Q+,R+,S+,T-,V+,X+,Y+}

var	inp,out:text;
	n,f1,f2,f3,t,f4,f5,l,k,m:longint;
	a,b:array[1..10000]of longint;
	c:array[1..10000]of record
						a,b,c:integer;
					   end;

function min(a,b:integer):integer;
begin
	if a<b then min:=a else min:=b;
end;

function max(a,b:integer):integer;
begin
	if a>b then max:=a else max:=b;
end;

procedure Sort(l, r: Integer);
var
  i, j, x, y: integer;
begin
  i := l; j := r; x := a[(l+r) DIV 2];
  repeat
	while a[i] < x do i := i + 1;
	while x < a[j] do j := j - 1;
	if i <= j then
	begin
	  y := a[i]; a[i] := a[j]; a[j] := y;
	  y := b[i]; b[i] := b[j]; b[j] := y;
	  i := i + 1; j := j - 1;
	end;
  until i > j;
  if l < j then Sort(l, j);
  if i < r then Sort(i, r);
end;

begin
	assign(inp,'');
	assign(out,'');

	rewrite(out);
	reset(inp);

	read(inp,n);

	for f1:=1 to n do begin
		read(inp,a[f1]);
		b[f1]:=f1;
	end;

	sort(1,n);

{	for f1:=1 to n do writeln(a[f1]);}

	for f1:=1 to (n-2) div 2 do begin
		f2:=n-(f1-1)*2;
		f3:=n-(f1-1)*2-1;
		f4:=a[f2]+a[2]*2+a[1];
		f5:=a[f2]+a[f3]+2*a[1];
		l:=l+1;
		if f4<f5 then begin
			c[l].a:=b[2];c[l].b:=b[1];c[l].c:=b[1];
			l:=l+1;
			c[l].a:=b[f2];c[l].b:=b[f3];c[l].c:=b[2];
			t:=t+f4;
		end else begin
			c[l].a:=b[1];c[l].b:=b[f2];c[l].c:=b[1];
			l:=l+1;
			c[l].a:=b[1];c[l].b:=b[f3];c[l].c:=b[1];
			t:=t+f5;
		end;
	end;

	if n mod 2 = 1 then begin
		l:=l+1;
		c[l].a:=b[1];c[l].b:=b[3];c[l].c:=b[1];
		t:=t+a[3]+a[1];
	end;
	t:=t+a[2];

	writeln(out,t);
{	for f1:=1 to l do begin
		writeln(out,c[f1].a,' ',c[f1].b,' ',c[f1].c);
	end;
	writeln(out,b[1],' ',b[2]);  }

	close(out);
end.
