#include <bits/stdc++.h>
using namespace std;
long long a[100000], sum[100001], m[100000];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
    m[i] = max(m[i - 1], m[i - 1] + a[i - 1]);
  }
  long long Max = 0;
  for (int i = 0; i < n - k + 1; i++) {
    long long p = sum[i + k] - sum[i];
    long long l = m[i - 1], r = m[n] - m[i + k];
    Max = max(Max, p + l + r);
  }
  printf("%lld\n", Max);
}
