#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<int, int>;
const LL INF = 9223372036854775807LL;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, K;
  cin >> N >> K;
  vector<int> aa(N);
  for (int i = 0; i < int(N); ++i) cin >> aa[i];
  vector<int> sums_not_including(N + 1, 0);
  vector<int> sums_only_positives(N + 1, 0);
  for (int i = int(1); i < int(N + 1); ++i) {
    sums_not_including[i] = sums_not_including[i - 1] + aa[i - 1];
    sums_only_positives[i] = sums_only_positives[i - 1] + max(0, aa[i - 1]);
  }
  LL rr = 0;
  for (int offset = 0; offset < int(N - K + 1); ++offset) {
    LL here = LL(sums_only_positives[offset]) + LL(sums_only_positives[N]) -
              sums_only_positives[offset + K];
    rr = max(rr, here);
    here += sums_not_including[offset + K] - LL(sums_not_including[offset]);
    rr = max(rr, here);
  }
  cout << rr << '\n';
  return 0;
}
