#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, k, a[100005], sum[100005];
int prefix(int l, int r) { return sum[r] - sum[l - 1]; }
int ans;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << (a[0] <= 0 ? 0 : a[0]);
    return 0;
  }
  sum[1] = a[1];
  for (int i = 2; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i <= n - k + 1; i++) {
    int x = max(sum[i - 1] + prefix(i + k + 1, n), prefix(i, i + k));
    ans = max(ans, x);
  }
  cout << ans;
  return 0;
}
