#include <bits/stdc++.h>
using namespace std;
int dy[4] = {-1, 1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int N, K;
long long a[100010];
long long sum_a[100010];
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  for (long long i = 0; i < (long long)(N); i++) cin >> a[i];
  for (long long i = 0; i < (long long)(N); i++) sum_a[i + 1] = sum_a[i] + a[i];
  long long sum = 0;
  pair<int, int> term;
  for (long long i = K; i < (long long)(N + 1); i++) {
    if (sum_a[i] - sum_a[i - K] > sum) {
      term = pair<int, int>(i - K, i);
      sum = sum_a[i] - sum_a[i - K];
    }
  }
  long long ans = sum;
  for (long long i = 0; i < (long long)(N); i++) {
    if (i < term.first || term.second <= i) {
      if (a[i] > 0) ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
