#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a[100005];
long long sum[100005], ans = 0;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 2; i <= n - k + 1; i++) {
    ans = max(ans, sum[i + k - 1] - sum[i - 1]);
  }
  long long t = ans;
  ans = max(ans, t + a[1]);
  ans = max(ans, a[1] + a[n]);
  printf("%lld", ans);
  return 0;
}
