#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, a[100000], ans = 0, sum = 0;
  std::cin >> n >> k;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    if (a[i] > 0) sum += a[i];
  }
  if (n == 1) {
    if (a[0] < 0)
      std::cout << 0 << std::endl;
    else
      std::cout << a[0] << std::endl;
  } else {
    for (int i = 0; i < n - k + 1; i++) {
      ll suma = sum, sumb = sum;
      for (int j = i; j < i + k; j++) {
        if (a[j] > 0)
          suma -= a[j];
        else
          sumb += a[j];
      }
      ll sumc = max(suma, sumb);
      ans = max(sumc, ans);
    }
    std::cout << ans << std::endl;
  }
}
