#include<bits/stdc++.h>usingnamespacestd;intN,K;intmain(){ifstreamcin("teamwork.in");ofstreamcout("teamwork.out");cin>>N>>K;vector<int>cows(N);vector<int>dp(N);for(inti=0;i<N;i++){cin>>cows[i];dp[i]=cows[i];}for(inti=1;i<N;i++){intcurrMax=cows[i];for(intk=0;k<K;k++){// range from j --> iintj=i-k;if(j<0){break;}currMax=max(currMax,cows[j]);dp[i]=max(dp[i],dp[j-1]+(currMax*(k+1)));}}cout<<dp[N-1];}