#include using namespace std; int main(){ int N, K; cin >> N >> K; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector dp(N + 1, 0); for (int i = 0; i < N; i++){ for (int j = max(i - K + 1, 0); j <= i; j++){ dp[i + 1] = max(dp[i + 1], dp[j]); } for (int j = max(i - K + 2, 0); j <= i; j++){ dp[j] = dp[j] + A[i]; } } long long ans = 0; for (int i = 0; i <= N; i++){ ans = max(ans, dp[i]); } cout << ans << endl; }