#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = (long long int)1e15;
long long int A[100005];
long long int S[100005];
long long int T[100005];
int main() {
  long long int N, K;
  cin >> N >> K;
  S[0] = T[0] = 0;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    cin >> A[i];
    S[i + 1] += S[i] + A[i];
    T[i + 1] += T[i] + std::max(0LL, A[i]);
  }
  long long int max = -INF;
  for (long long int(i) = (0); (i) < (N); ++(i)) {
    if (i + K > N) break;
    long long int m =
        T[i] + std::max(S[i + K] - S[i], T[i + K] - T[i]) + T[N] - T[i + K];
    max = std::max(max, m);
  }
  cout << max << endl;
  return 0;
}
