#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp) {
  for (auto x : mp) os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template <typename T, long long SIZE>
long long array_length(const T (&)[SIZE]) {
  return SIZE;
}
template <typename T, long long N>
void print(const T (&a)[N], long long s = N, long long t = -1, bool f = true) {
  if (t == -1) {
    for (long long i = 0; i < s; i++) {
      if (i) cout << " ";
      cout << a[i];
    }
  } else
    for (long long i = s; i < t; i++) {
      if (i != s) cout << " ";
      cout << a[i];
    }
  if (f) cout << "\n";
}
template <typename T, long long N1, long long N2>
void print(const T (&a)[N1][N2], long long h = N1, long long w = N2) {
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      cout << a[i][j] << " \n"[j == w - 1];
    }
  }
}
const long long inf = 1e9 + 7;
const long long INF = 1e18 + 7;
long long a[200000], b[2][200000];
signed main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i < n + 1; i++) cin >> a[i];
  for (long long i = 1; i < n + 1; i++) {
    b[0][i] = max(0LL, a[i]);
    b[1][i] = min(0LL, a[i]);
    b[0][i] += b[0][i - 1];
    b[1][i] += b[1][i - 1];
  }
  long long ans = 0;
  for (long long i = 1; i < n + 1; i++) {
    long long l = i, r = i + k;
    if (r > n) break;
    long long sum = 0;
    sum += (b[0][l - 1] - b[0][0]);
    sum += (b[0][n] - b[0][r - 1]);
    long long x = b[0][r - 1] - b[0][l - 1];
    long long y = b[1][r - 1] - b[1][l - 1];
    sum += max(0LL, x + y);
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
