#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 58;
struct CumulativeSum {
  vector<long long> data;
  CumulativeSum(long long sz) : data(++sz, 0){};
  inline void add(long long k, long long x) { data[k] += x; }
  void build() {
    for (long long i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }
  inline long long query(long long k) {
    if (k < 0) return (0);
    return (data[min(k, (long long)data.size() - 1)]);
  }
};
CumulativeSum sum(100000), sum2(100000);
long long dp[100000][3];
long long A[100000];
long long N, K;
long long sums1(long long l, long long r) {
  return (sum.query(r) - sum.query(l));
}
long long sums2(long long l, long long r) {
  return (sum2.query(r) - sum2.query(l));
}
signed main() {
  cin >> N >> K;
  long long all = 0;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    sum.add(i, max(0LL, A[i]));
    sum2.add(i, A[i]);
    all += A[i];
  }
  sum.build();
  sum2.build();
  long long ret = 0;
  for (long long i = 0; i <= N - K; i++) {
    ret = max(ret, sums1(-1, i - 1) + sums1(i + K - 1, N - 1) +
                       sums2(i - 1, i + K - 1));
    ret = max(ret, sums2(-1, i - 1) + sums2(i + K - 1, N - 1) +
                       sums1(i - 1, i + K - 1));
  }
  cout << ret << endl;
}
