#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  vector<long long> sum(N + 1);
  sum[0] = 0;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
  }
  long long mi = 9223372036854775807, ma = 9223372036854775807 * -1;
  vector<long long> mitmp;
  vector<long long> matmp;
  for (long long i = (K); i <= (N); ++i) {
    if (ma == sum[i] - sum[i - K]) matmp.push_back(i - K);
    if (ma < sum[i] - sum[i - K]) {
      ma = max(ma, sum[i] - sum[i - K]);
      matmp.clear();
      matmp.push_back(i - K);
    }
    if (mi == sum[i] - sum[i - K]) mitmp.push_back(i - K);
    if (mi > sum[i] - sum[i - K]) {
      mi = min(mi, sum[i] - sum[i - K]);
      mitmp.clear();
      mitmp.push_back(i - K);
    }
  }
  long long maans = 0, mians = 0;
  for (long long j = 0; j < matmp.size(); j++) {
    long long cnt = 0;
    for (long long i = 0; i < N; i++) {
      if (A[i] > 0 && !(matmp[j] <= i && i <= matmp[j] + K - 1)) {
        cnt += A[i];
      }
    }
    maans = max(maans, cnt);
  }
  for (long long j = 0; j < mitmp.size(); j++) {
    long long cnt = 0;
    for (long long i = 0; i < N; i++) {
      if (A[i] > 0 && !(mitmp[j] <= i && i <= mitmp[j] + K - 1)) {
        cnt += A[i];
      }
    }
    mians = max(mians, cnt);
  }
  cout << max(mians, maans + ma) << endl;
  return 0;
}
