#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline bool minimize(T1& a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2>
inline bool maximize(T1& a, T2 b) {
  return a < b && (a = b, 1);
}
template <class T>
void operator>>(istream& ist, vector<T>& vs) {
  for (auto& e : vs) cin >> e;
}
int const inf = 1 << 29;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  vector<long long> sum(N + 1);
  vector<int> pSum(N + 1);
  for (int i = 0; i < (int)N; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
    pSum[i + 1] = pSum[i];
    if (a[i] > 0) {
      pSum[i + 1] += a[i];
    }
  }
  long long NG = -(1LL << 50);
  long long ans = NG;
  for (int startK = 0; startK < (int)N - K + 1; startK++) {
    long long SB = sum[startK + K] - sum[startK];
    long long cand = pSum[startK] + pSum[N] - pSum[startK + K];
    if (SB > 0) cand += SB;
    ans = max(ans, cand);
  }
  cout << (ans == NG ? 0 : ans) << endl;
  return 0;
}
