#include <bits/stdc++.h>
using namespace std;
int n, k;
long long arr[100005];
long long ps[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    ps[i] = ps[i - 1] + arr[i];
  }
  long long temp = -100000000000000000;
  int awal = -1;
  for (int i = k; i <= n; i++) {
    long long x = ps[i] - ps[i - k];
    if (x > temp) {
      temp = x;
      awal = i - k + 1;
    }
  }
  long long ans = temp;
  for (int i = 1; i <= n; i++) {
    if (awal != -1 && (i >= awal && i <= (awal + k - 1))) {
      continue;
    }
    if (arr[i] > 0) ans += arr[i];
  }
  cout << ans << endl;
}
