#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int N;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  long long total = 0;
  for (int i = 0; i < K; i++) total += a[i];
  long long max_total = total, min_total = total;
  int max_i = K - 1, min_i = K - 1;
  for (int i = K; i <= N - 1; i++) {
    total -= a[i - K];
    total += a[i];
    if (total > max_total) {
      max_total = total;
      max_i = i;
    } else if (total < min_total) {
      min_total = total;
      min_i = i;
    }
  }
  long long ans1 = 0, ans2 = 0;
  for (int i = 0; i < N; i++) {
    if (i + (K - 1) >= max_i && i <= max_i) {
      ans1 += a[i];
    } else if (a[i] > 0) {
      ans1 += a[i];
    }
    if (i + (K - 1) >= min_i && i <= min_i) {
    } else if (a[i] > 0) {
      ans2 += a[i];
    }
  }
  cout << (ans1 > ans2 ? ans1 : ans2);
}
