#include <bits/stdc++.h>
using namespace std;
int K;
int N;
int a[100000 + 1];
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long cumsum[100000 + 1];
  cumsum[0] = 0;
  long long all_pos = 0;
  for (int i = 1; i <= N; i++) {
    cumsum[i] = cumsum[i - 1] + a[i - 1];
    all_pos += a[i - 1];
  }
  long long mx = 0;
  for (int i = 0; i <= N - K; i++) {
    long long black = cumsum[i + K + 1] - cumsum[i];
    long long white = 0;
    mx = max(mx, (all_pos - black) + max(black, white));
  }
  cout << mx << endl;
  return 0;
}
