#include <bits/stdc++.h>
using namespace std;
int n, k, sum[200001], zj, nk, nj, dz, df;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> sum[i];
    if (sum[i] > 0) zj += sum[i];
  }
  for (int i = 1; i <= n - k + 1; i++) {
    for (int j = 1; j <= k; j++)
      if (sum[j] > 0) nk += sum[j];
    if (nk < nj) dz = nk;
  }
  for (int i = 1; i <= n - k + 1; i++) {
    for (int j = 1; j <= k; j++)
      if (sum[i] < 0) nj += sum[i];
    if (nj > df || df == 0) df = nj;
  }
  cout << max(zj + df, zj - dz);
}
