#include <bits/stdc++.h>
using namespace std;
const long mod = 1e9 + 7;
const int size = 1e5 + 1;
const int inf = 1e9;
int main() {
  int N, K;
  cin >> N >> K;
  long a;
  long sum[2][N + 1];
  sum[0][0] = sum[1][0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    sum[0][i + 1] = sum[0][i] + a;
    sum[1][i + 1] = sum[1][i] + max(a, 0L);
  }
  for (int J = 0; J < 2; J++) {
    for (int I = 0; I < N + 1; I++) {
      cout << (I ? " " : "") << sum[J][I];
    }
    cout << endl;
    ;
  };
  long ans = 0;
  for (int i = 0; i < N - K + 1; i++) {
    int j = i + K;
    long res = 0;
    res += sum[1][i] - sum[1][0];
    res += max(sum[0][j] - sum[0][i], 0L);
    res += sum[1][N] - sum[1][j];
    ans = max(ans, res);
  }
  cout << ans << endl;
}
