#include <bits/stdc++.h>
int descending_compare(const void *a, const void *b) {
  if (*(int *)a > *(int *)b) {
    return -1;
  } else if (*(int *)a == *(int *)b) {
    return 0;
  } else {
    return 1;
  }
}
int ascending_compare(const void *a, const void *b) {
  if (*(int *)a < *(int *)b) {
    return -1;
  } else if (*(int *)a == *(int *)b) {
    return 0;
  } else {
    return 1;
  }
}
int lower_bound(int *a, int n, int key) {
  int ng, mid, ok;
  ng = -1, ok = n - 1;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    if (key <= a[mid]) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  if (a[ok] >= key) return ok;
  return n;
}
unsigned long gcd(unsigned long x, unsigned long y) {
  if (y == 0) {
    return x;
  } else if (x > y) {
    return gcd(y, x % y);
  } else {
    return gcd(x, y % x);
  }
}
unsigned long lcm(unsigned long x, unsigned long y) {
  unsigned long g = gcd(x, y);
  return x * y / g;
}
long long factorial(int x) {
  long long rtn = 1;
  int i;
  for (i = x; i > 1; i--) {
    rtn = (rtn * i);
  }
  return rtn;
}
long long mod = 1000000007;
long long mod_pow(long long x, long long n) {
  long long res = 1;
  for (int i = 0; i < 60; i++) {
    if (n >> i & 1) res = res * x % mod;
    x = x * x % mod;
  }
  return res;
}
long long imos[100005];
int a[100005];
int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  long long score = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) score += a[i];
  }
  imos[0] = a[0];
  for (int i = 1; i < n; i++) {
    imos[i] = imos[i - 1] + a[i];
  }
  long long min = 100000000000005;
  int mini;
  long long max = -100000000000005;
  int maxi;
  for (int i = k - 1; i < n; i++) {
    if (i - k < 0) {
      if (imos[i] < min) {
        min = imos[i];
        mini = i;
      }
      if (imos[i] > max) {
        max = imos[i];
        maxi = i;
      }
    } else {
      if (imos[i] - imos[i - k] < min) {
        min = imos[i] - imos[i - k];
        mini = i;
      }
      if (imos[i] - imos[i - k] > max) {
        max = imos[i] - imos[i - k];
        maxi = i;
      }
    }
  }
  long long max_score = 0;
  long long min_score = 0;
  for (int i = maxi - k + 1; i <= maxi; i++) {
    if (a[i] < 0) max_score += a[i];
  }
  for (int i = mini - k + 1; i <= mini; i++) {
    if (a[i] > 0) min_score -= a[i];
  }
  if (score + min_score > score + max_score) {
    score = score + min_score;
  } else {
    score = score + max_score;
  }
  if (score < 0) score = 0;
  printf("%lld\n", score);
}
