#include <bits/stdc++.h>
using namespace std;
long long a[100005], ans, n, k;
bool paints[100005];
inline void paint(unsigned long begin, unsigned long end, bool color) {
  if (color)
    for (unsigned int i = begin; i <= end; ++i)
      if (!paints[i]) paints[i] = true;
  if (!color)
    for (unsigned int i = begin; i <= end; ++i)
      if (paints[i]) paints[i] = false;
}
int main() {
  scanf("%lld %lld", &n, &k);
  scanf("%lld", a);
  for (unsigned int i = 1; i < n; ++i) {
    scanf("%lld", a + i);
    a[i] += a[i - 1];
  }
  if (a[k - 1] > 0) paints[0] = true;
  if (n == k) {
    if (a[n - 1] > 0) {
      printf("%lld", a[n - 1]);
      return 0;
    } else {
      printf("0");
      return 0;
    }
  }
  for (unsigned int st = 1, ed = k; ed < n; ++st, ++ed) {
    if (a[ed] - a[st - 1] >= 0) paint(st, ed, true);
  }
  for (unsigned int st = 1, ed = k; ed < n - 1; ++st, ++ed) {
    if (a[ed] - a[st - 1] < 0) {
      if (st > 1)
        if (a[ed - 1] - a[st - 1] + a[ed] > 0) continue;
      paint(st, ed, false);
    }
    if (a[ed] - a[st - 1] >= 0) paint(st, ed, true);
  }
  for (unsigned int i = 1; i < n; ++i)
    if (paints[i]) ans += a[i] - a[i - 1];
  if (paints[0]) ans += a[0];
  printf("%lld", ans);
  return 0;
}
