#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1001001001001001001;
vector<int> D;
int N, K;
int a[100002];
long long int wa[100002];
long long int Kwa[100002];
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  long long int large = 1, largen = -1;
  long long int small = -1, smallen = -1;
  for (int i = 0; i < N; i++) {
    if (i == 0)
      wa[i] = a[i];
    else
      wa[i] = a[i] + wa[i - 1];
    if (i >= K - 1) {
      if (i - K >= 0)
        Kwa[i] = wa[i] - wa[i - K];
      else
        Kwa[i] = wa[i];
      if (Kwa[i] >= large) {
        large = Kwa[i];
        largen = i;
      }
      if (Kwa[i] <= small) {
        small = Kwa[i];
        smallen = i;
      }
    }
  }
  long long int ans1 = 0, ans2 = 0;
  if (largen)
    for (int i = 0; i < N; i++) {
      if (i == largen - K + 1) {
        ans1 += Kwa[largen];
        i = largen;
      } else
        ans1 += max(a[i], 0);
    }
  if (smallen)
    for (int i = 0; i < N; i++) {
      if (i == smallen - K + 1) {
        ;
        i = smallen;
      } else
        ans2 += max(a[i], 0);
    }
  printf("%lld\n", max(ans1, ans2));
}
