#include <bits/stdc++.h>
using namespace std;
long long sum, A[100100];
int N, K;
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  int L = -1, R = -1;
  for (int i = 0; i < N; i++) {
    if (A[i] > 0 && L == -1) L = i;
    if (L != -1 && A[i] <= 0) R = i;
  }
  for (int i = L; i < R; i++) sum += A[i];
  for (int i = L; i < R - K; i++) {
    long long So = sum;
    for (int j = i; j < i + K; j++) sum -= A[j];
    sum = max(sum, So);
  }
  cout << sum << endl;
  return 0;
}
