#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];
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] = dp[i - 1];
    long long val = LLONG_MIN;
    for (int j = i - k + 1; j <= i; j++) {
      val = max(val, pref[j] - pref[i - k]);
      if (i > k) val = max(val, pref[i] - pref[j - 1]);
    }
    dp[i] = max(dp[i], dp[i - k] + val);
  }
  cout << dp[n];
  return 0;
}
