#include <bits/stdc++.h>
namespace Program {
using namespace std;
class Solver {
 private:
  int N, K;
  int a;
  queue<int> qi;
  vector<long long int> viA;
  vector<long long int> viB;
  long long int sumTotal = 0LL;
  long long int sumA = 0LL;
  long long int sumB = 0LL;

 public:
  Solver() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
      cin >> a;
      qi.push(a);
      sumA += a;
      sumTotal += a < 0 ? 0 : a;
      if (i >= K - 1) {
        viA.push_back(sumA);
        long long int qf = qi.front();
        sumA = sumA - qf;
        qi.pop();
        sumB += qf < 0 ? 0 : qf;
        viB.push_back(sumB);
      } else {
        viA.push_back(0);
      }
    }
    while (!qi.empty()) {
      sumB += qi.front() < 0 ? 0 : qi.front();
      viB.push_back(sumB);
      qi.pop();
    }
  }
  void Solve() {
    long long int score = 0LL;
    for (int i = K - 1; i < N; i++) {
      int b = i - K >= 0 ? viB[i - K] : 0;
      long long shiro = b + sumTotal - viB[i];
      score = max(shiro, score);
      long long kuro = shiro + viA[i];
      score = max(kuro, score);
    }
    cout << score << endl;
  }
};
}  // namespace Program
int main() {
  void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
  Program::Solver obj;
  (obj.*pSolve)();
  return 0;
}
