#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932;
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;
long long sum[100005];
bool used[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  long long value = 0;
  int pos = -1;
  for (int i = 0; i + k <= n; ++i) {
    if (sum[i + k] - sum[i] > value) {
      value = sum[i + k] - sum[i];
      pos = i;
    }
  }
  long long res = value;
  if (pos != -1) {
    for (int i = 0; i < k; ++i) {
      used[pos + i] = true;
    }
    for (int i = 0; i < n; ++i) {
      if (used[i]) continue;
      if (a[i] > 0) {
        res += a[i];
        used[i] = true;
      }
    }
  } else {
    for (int i = 0; i + k <= n; ++i) {
      if (used[i]) continue;
      if (a[i] > 0) {
        res += a[i];
        used[i] = true;
      }
    }
    for (int i = n - 1; i - k >= 0; --i) {
      if (used[i]) continue;
      if (a[i] > 0) {
        res += a[i];
        used[i] = true;
      }
    }
  }
  cout << res << endl;
}
