#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[100010];
int B[100010];
int f(int *X) {
  int t = 0, g = 0;
  for (int i = 0; i < N; i++) {
    g += X[i];
    if (i < K - 1)
      t = max(0, g);
    else
      t = max(0, t + max(X[i], 0));
  }
  return t;
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[N - 1 - i] = A[i];
  }
  cout << max(f(A), f(B)) << "\n";
  return 0;
}
