#include <bits/stdc++.h>
static FILE *szpFpI;
static int si1Mass[100000];
static int siMCnt;
static int siSCnt;
int fGetSel(int *pipSNo, long long *plpSum) {
  int i;
  *plpSum = 0;
  *pipSNo = 0;
  for (i = 0; i < siSCnt; i++) {
    *plpSum += (long long)si1Mass[i];
  }
  long long llSum = *plpSum;
  for (i = 1; i < siMCnt - siSCnt + 1; i++) {
    llSum += (long long)si1Mass[siSCnt + i - 1] - (long long)si1Mass[i - 1];
    if (*plpSum < llSum) {
      *plpSum = llSum;
      *pipSNo = i;
    }
  }
  if (*plpSum > 0) {
    return 0;
  }
  *plpSum = 0;
  *pipSNo = 0;
  for (i = 0; i < siSCnt; i++) {
    *plpSum += (long long)si1Mass[i];
  }
  llSum = *plpSum;
  for (i = 1; i < siMCnt - siSCnt + 1; i++) {
    llSum += (long long)si1Mass[siSCnt + i - 1] - (long long)si1Mass[i - 1];
    if (*plpSum > llSum) {
      *plpSum = llSum;
      *pipSNo = i;
    }
  }
  *plpSum = 0;
  return 0;
}
int fMain(int piTNo) {
  int i;
  char lc1Buf[1024], lc1Out[1024];
  szpFpI = stdin;
  fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
  sscanf(lc1Buf, "%d%d", &siMCnt, &siSCnt);
  for (i = 0; i < siMCnt; i++) {
    fscanf(szpFpI, "%d", &si1Mass[i]);
  }
  fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
  int liSNo;
  long long llSum;
  fGetSel(&liSNo, &llSum);
  for (i = 0; i < liSNo; i++) {
    if (si1Mass[i] > 0) {
      llSum += (long long)si1Mass[i];
    }
  }
  for (i = liSNo + siSCnt; i < siMCnt; i++) {
    if (si1Mass[i] > 0) {
      llSum += (long long)si1Mass[i];
    }
  }
  sprintf(lc1Out, "%lld\n", llSum);
  printf("%s", lc1Out);
  return 0;
}
int main() {
  fMain(0);
  return 0;
}
