#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<long long> b(N + 1, 0);
  for (int i = 1; i < N + 1; i++) {
    b[i] = b[i - 1] + (a[i - 1] > 0 ? a[i - 1] : 0);
  }
  long long ans = 0;
  for (int i = 0; i < N - K + 1; i++) {
    long long sum = (b[i] - b[0]) + (b[N] - b[i + K]);
    sum += max(0, accumulate(a.begin() + i, a.begin() + i + K, 0));
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
