program ideone;
 
var n, i, l, r:longint;
	a:array[1..100000] of longint;
	ans:int64;
 
function min(a:longint; b:longint):int64;
begin
	if a > b
	then	
		min := b
	else
		min := a;
end;
 
function max(a:int64; b:int64):int64;
begin
	if a < b
	then
		max := b
	else
		max := a;
end;
 
begin
	readln(n);
	for i := 1 to n do
		read(a[i]);
	ans := 0;
	l := 1; r := n;
	for i := 1 to n do begin
		ans := max(ans, min(a[l], a[r]) * (r-l));
		if a[l] <= a[r]
		then inc(l)
		else dec(r);
	end;
	writeln(ans);
end.
