program cojs1693;
uses math;
const
maxn=3000;
var
f,v:array[0..maxn]of longint;
n,m,i,j:longint;
begin
assign(input,'cool.in');reset(input);
assign(output,'cool.out');rewrite(output);
readln(n,m);
for i:=0 to n do
read(v[i]);
for i:=0 to n do
f[i]:=(n+m)*v[0];
for i:=1 to n do
for j:=i to n do
f[j]:=max(f[j],f[j-i]+v[i]-v[0]);
writeln(f[n]);
close(input);close(output);
end.