//#define _GLIBCXX_DEBUG #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #define endl '\n' #define lfs cout<= (ll)(n); i--) using ll = int; using ld = long double; const ll MOD1 = 1e9+7; const ll MOD9 = 998244353; const ll INF = 1e9; using P = pair; template bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;} template bool chmax(T1 &a,T2 b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>&v,ll h,ll w){for(ll i=0;i&v,ll h,ll w){for(ll i=0;i void debug(vector&v,ll n){if(n!=0)cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} vectordx={1,-1,0,0,1,1,-1,-1}; vectordy={0,0,1,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } template ostream &operator<<(ostream &os, const pair&p){ return os << p.first << " " << p.second; } //mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res=0,buf=0; bool judge = true; ll n,m;cin>>n>>m; vectora(n); rep(i,0,n)cin>>a[i]; auto dp=make_v(2,n,n,n,-INF); rep(i,0,n)dp[0][i][i][i]=a[i]*m; ll now=0; rrep(i,0,m){ if(i<=4)rep(j,0,n)dp[now^1][j][j][j]=-INF; rep(j,0,n){ ll addl,addr; if(j>=1)addl=a[j-1]*i; if(j0){ if(l==j)chmax(dp[now^1][j-1][l-1][r],dp[now][j][l][r]+addl); else chmax(dp[now^1][j-1][l][r],dp[now][j][l][r]); } if(jret(n,-INF); rep(l,0,n)rep(r,l,n)rep(j,0,n){ chmax(ret[j],dp[now][j][l][r]); } rep(i,0,n)cout<