#include<iostream>
#include<climits>
#include<fstream>
//#define fi cin
//#define fo cout
using namespace std;
ifstream fi("cool.in");
ofstream fo("cool.out");
int n, m, v[6010], w[6010], dp[6010], ans = INT_MIN;
main()
{
ios::sync_with_stdio(0);
fi >> n >> m;
for(int i = 1; i <= n + 1; i ++)
{
fi >> v[i];
w[i] = i - 1;
}
for(int i = 0; i <= n; i ++)
dp[i] = (m + n) * v[1];
for(int i = 1; i <= n + 1; i ++)
for(int j = w[i]; j <= n; j ++)
dp[j] = max(dp[j], dp[j - w[i]] + v[i] - v[1]);
for(int i = 0; i <= n; i ++)
ans = max(ans, dp[i]);
fo << ans;
}