#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  int N, K;
  int *a;
  scanf("%d%d", &N, &K);
  a = (int *)malloc(N * sizeof(int));
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  int max = 0, index[N - K + 1], indexcnt = 0;
  for (int i = 0; i < N - K + 1; i++) {
    int tmp = 0;
    for (int j = 0; j < K; j++) {
      tmp += a[i + j];
    }
    if (max < tmp) {
      max = tmp;
      indexcnt = 1;
      index[0] = i;
    } else if (max == tmp) {
      index[indexcnt] = i;
      indexcnt++;
    }
  }
  if (max == 0) {
    indexcnt = 1;
    K = 0;
    index[0] = 0;
  }
  int ans = 0;
  for (int i = 0; i < indexcnt; i++) {
    int tmp = max;
    for (int j = 0; j < N; j++) {
      if (index[i] <= j && j < index[i] + K) {
      } else {
        if (a[j] > 0) tmp += a[j];
      }
    }
    if (ans < tmp) ans = tmp;
  }
  printf("%d\n", ans);
  return 0;
}
