#include <bits/stdc++.h>
using namespace std;
int N, K, a[100009];
long long ans, sp[100009], s[100009];
int qry(int st, int dr) { return max(0LL, s[dr] - s[st - 1]); }
int main() {
  scanf("%d %d", &N, &K), ans = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    int x = 0;
    if (a[i] > x) x = a[i];
    sp[i] = sp[i - 1] + x, s[i] = s[i - 1] + a[i];
  }
  for (int i = 1; i <= N - K + 1; i++) {
    long long curr = sp[i - 1] + sp[N] - sp[i + K - 1] + qry(i, i + K - 1);
    if (curr > ans) ans = curr;
  }
  printf("%lld\n", ans);
  return 0;
}
