#include <bits/stdc++.h>
using namespace std;
const long long INF = (0x7FFFFFFFL);
const long long INFF = (0x7FFFFFFFFFFFFFFFL);
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const long long MOD = 1e9 + 7;
const long long MODD = 998244353;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1.0);
const double EPS = 1e-9;
const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
long long dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
long long dy[9] = {0, 1, 0, -1, -1, -1, 1, 1, 0};
template <typename T>
void MACRO_VAR_Scan(T &t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &...rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &j) {
  o << "{";
  for (long long i = 0; i < (long long)j.size(); ++i)
    o << (i > 0 ? ", " : "") << j[i];
  o << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &j) {
  o << "{" << j.first << ", " << j.second << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
inline long long print(void) {
  cout << endl;
  return 0;
}
template <class Head>
long long print(Head &&head) {
  cout << head;
  print();
  return 0;
}
template <class Head, class... Tail>
long long print(Head &&head, Tail &&...tail) {
  cout << head << " ";
  print(forward<Tail>(tail)...);
  return 0;
}
inline long long debug(void) {
  cerr << endl;
  return 0;
}
template <class Head>
long long debug(Head &&head) {
  cerr << head;
  debug();
  return 0;
}
template <class Head, class... Tail>
long long debug(Head &&head, Tail &&...tail) {
  cerr << head << " ";
  debug(forward<Tail>(tail)...);
  return 0;
}
template <typename T>
void PA(T &a) {
  long long ASIZE = sizeof(a) / sizeof(a[0]);
  for (long long ii = 0; ii < ASIZE; ++ii) {
    cout << a[ii] << " \n"[ii == ASIZE - 1];
  }
}
template <typename T>
void PV(T &v) {
  long long VSIZE = v.size();
  for (long long ii = 0; ii < VSIZE; ++ii) {
    cout << v[ii] << " \n"[ii == VSIZE - 1];
  }
}
inline long long YES(bool x) {
  cout << ((x) ? "YES" : "NO") << endl;
  return 0;
}
inline long long Yes(bool x) {
  cout << ((x) ? "Yes" : "No") << endl;
  return 0;
}
inline long long yes(bool x) {
  cout << ((x) ? "yes" : "no") << endl;
  return 0;
}
inline long long yES(bool x) {
  cout << ((x) ? "yES" : "nO") << endl;
  return 0;
}
inline long long Yay(bool x) {
  cout << ((x) ? "Yay!" : ":(") << endl;
  return 0;
}
template <typename A, typename B>
void sankou(bool x, A a, B b) {
  cout << ((x) ? (a) : (b)) << endl;
}
inline long long MOP(long long x, long long n, long long m = MOD) {
  long long r = 1;
  while (n > 0) {
    if (n & 1) (r *= x) %= m;
    (x *= x) %= m;
    n >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1ll;
  do {
    if (b & 1) c *= 1ll * a;
    a *= 1ll * a;
  } while (b >>= 1);
  return c;
}
template <typename T, typename A, typename B>
inline bool between(T x, A a, B b) {
  return ((a <= x) && (x < b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename A, typename B>
inline bool chmax(A &a, const B &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, typename B>
inline bool chmin(A &a, const B &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct abracadabra {
  abracadabra() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(5);
  };
} ABRACADABRA;
template <class T>
struct CumulativeSum {
  vector<T> data;
  CumulativeSum(long long sz, T init = 0) : data(sz, init){};
  void add(long long k, T x) { data[k] += x; }
  void build() {
    for (long long i = 1; i < (long long)data.size(); ++i) {
      data[i] += data[i - 1];
    }
  }
  T query(long long k) {
    if (k < 0) return 0;
    return data[min(k, (long long)data.size() - 1)];
  }
  T query(long long l, long long r) {
    T ret = (data[min(r - 1, (long long)data.size() - 1)]);
    if (l >= 0) ret -= (data[min(l - 1, (long long)data.size() - 1)]);
    return ret;
  }
  T operator[](const long long &k) { return data[k]; }
  void debug() {
    for (long long i = 0; i < (long long)data.size(); ++i)
      cerr << data[i] << ' ';
    cerr << '\n';
  }
};
signed main() {
  long long N, K;
  MACRO_VAR_Scan(N, K);
  ;
  vector<long long> A(N);
  for (auto &i : A) cin >> i;
  ;
  CumulativeSum<long long> pos(N), both(N);
  for (long long i = long long(0); i < long long(N); ++i) {
    if (A[i] > 0) pos.add(i, A[i]);
    both.add(i, A[i]);
  }
  pos.build();
  both.build();
  long long res = -INFF;
  for (long long left = long long(0); left < long long(N - K + 1); ++left) {
    long long right = left + K;
    long long tmp = max<long long>(0, both.query(left, right));
    if (left - 1 >= 0) tmp += pos.query(left - 1);
    tmp += pos.query(N - 1) - pos.query(right - 1);
    chmax(res, tmp);
  }
  print(res);
}
