#include <bits/stdc++.h>
using ll = long long;
ll min(ll a, ll b) {
  if (a >= b)
    return b;
  else
    return a;
}
ll max(ll a, ll b) {
  if (a >= b)
    return a;
  else
    return b;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const unsigned long long INF3 = 18446744073709551600LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = {0};
int main() {
  ll n, k, b[100010], c[100010], ans = 0;
  std::cin >> n >> k;
  b[0] = 0, c[0] = 0;
  for (int i = 1; i <= n; i++) {
    ll a;
    std::cin >> a;
    b[i] += b[i - 1] + a;
    if (a > 0)
      c[i] += c[i - 1] + a;
    else
      c[i] = c[i - 1];
  }
  if (n == k) {
    if (b[n] > 0)
      std::cout << b[n] << std::endl;
    else
      std::cout << 0 << std::endl;
  } else {
    for (int i = 1; i < n - k + 2; i++) {
      ll suma = c[n] - c[i + k - 1], sumb = c[n] - c[i + k - 1];
      suma += c[i - 1], sumb += c[i - 1];
      sumb += b[i + k - 1] - b[i - 1];
      ll sumc = max(suma, sumb);
      ans = max(sumc, ans);
    }
    std::cout << ans << std::endl;
  }
}
