#include <bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
template <class T>
void debug(T head) {
  cerr << head << endl;
}
template <class Head, class... Body>
void debug(Head head, Body... body) {
  if (DEBUG) {
    cerr << head << " ";
    debug(body...);
  }
}
const int INF = INT_MAX / 4;
const int MOD = 1000000007;
const double EPS = 1e-14;
int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.precision(10);
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  long sum_K_length = 0;
  for (int i = 0; i < K; ++i) {
    sum_K_length += a[i];
  }
  long sum_min = sum_K_length;
  long sum_max = sum_K_length;
  int sum_min_start_idx = 0;
  int sum_max_start_idx = 0;
  for (int i = K; i < N; ++i) {
    sum_K_length = sum_K_length - a[i - K] + a[i];
    if (sum_min > sum_K_length) {
      sum_min = sum_K_length;
      sum_min_start_idx = i - K + 1;
    }
    if (sum_max < sum_K_length) {
      sum_max = sum_K_length;
      sum_max_start_idx = i - K + 1;
    }
  }
  sum_min = 0;
  for (int i = 0; i < N; ++i) {
    if (i < sum_min_start_idx || sum_min_start_idx + K - 1 < i) {
      if (a[i] > 0) {
        sum_min += a[i];
      }
    }
    if (i < sum_max_start_idx || sum_max_start_idx + K - 1 < i) {
      if (a[i] > 0) {
        sum_max += a[i];
      }
    }
  }
  cout << max(sum_min, sum_max) << endl;
  return 0;
}
