#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int NN = 20;
const int INF = 1e9 + 7;
int n, k;
long long pref[N], dp[N];
bool was[N];
long long get(int l, int r) {
  long long ans = 0;
  for (int i = l; i <= r; i++) {
    for (int len = 1; len <= k && i + len - 1 <= r; len++) {
      ans = min(ans, pref[i + len - 1] - pref[i - 1]);
    }
  }
  return pref[r] - pref[l - 1] - ans;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> pref[i];
    pref[i] += pref[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    if (i < k) continue;
    dp[i] = max(dp[i - 1], dp[i - k] + pref[i] - pref[i - k]);
    if (i > k) {
      int beg = i - k + 1;
      for (int j = 1; j < beg; j++) {
        if (beg - j < k && j - k + 1 >= 1) {
          dp[i] = max(dp[i], dp[j - k] + get(j - k + 1, i));
        }
      }
    }
  }
  cout << "\n";
  cout << dp[n];
  return 0;
}
