#include <bits/stdc++.h>
using namespace std;
int a[10007], b[10007], asum[10007], bsum[10007], ans1, ans2, ans, N, K;
int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    asum[i] = asum[i - 1] + a[i];
  }
  for (int i = 1; i <= N - 2 * K; i++)
    if (a[i] > 0) ans1 += a[i];
  int tmp1 = asum[N] - asum[N - 2 * K + 1];
  ans1 = max(ans1, ans1 + tmp1);
  for (int i = N - 2 * K + 1; i <= N - K + 1; i++)
    ans1 = max(ans1, ans1 + tmp1 - (asum[i + K - 1] - asum[i - 1]));
  for (int i = 1; i <= N; i++) {
    b[i] = a[N - i + 1];
    bsum[i] = bsum[i - 1] + b[i];
  }
  for (int i = 1; i <= N - 2 * K; i++)
    if (b[i] > 0) ans2 += b[i];
  int tmp2 = bsum[N] - bsum[N - 2 * K + 1];
  ans2 = max(ans2, ans2 + tmp2);
  for (int i = N - 2 * K + 1; i <= N - K + 1; i++)
    ans2 = max(ans2, ans2 + tmp2 - (bsum[i + K - 1] - bsum[i - 1]));
  ans = max(ans1, ans2);
  return 0;
}
