/*
#include <stdio.h>
// 2336, 청송 황금 사과 0
int main() {
int fruits[2][2] = {{2, 3}, {3, 5}};
int k = 500;
int pattern[6] = {8};
for (int i = 0; i < 2; i++) {
for (int j = fruits[i][0]; j < 6; j += fruits[i][0]) {
pattern[j] += fruits[i][1];
}
}
int days;
for (days = 0; k > 0 || pattern[days % 6] == 0; days++) {
k -= pattern[days % 6];
}
int year, month, day;
int leap = 0;
for (year = 2023; days >= 365; year++) {
leap = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
days -= 365 + leap;
}
if (days == -1) {
year -= 1;
month = 12;
day = 31;
} else {
int monthLengths[13] = {0};
for (int i = 1; i <= 7; i++) {
monthLengths[i] = 30 + i % 2;
}
for (int i = 8; i <= 12; i++) {
monthLengths[i] = 31 - i % 2;
}
monthLengths[2] = 28 + leap;
for (month = 1; days >= monthLengths[month]; month++) {
days -= monthLengths[month];
}
day = days + 1;
}
printf("%04d/%02d/%02d", year, month, day);
return 0;
}
*/
/*
#include <stdio.h>
// 2337. 청송 황금 사과 1
// 2338. 청송 황금 사과 2
int main() {
int fruits[2][2] = {{2}, {3}};
int k;
scanf("%d\n%d %d", &k, &fruits[0][1], &fruits[1][1]);
int pattern[6][2] = {0};
for (int i = 0; i < 2; i++) {
pattern[0][i] = fruits[i][1];
for (int j = fruits[i][0]; j < 6; j += fruits[i][0]) {
pattern[j][i] = fruits[i][1];
}
}
int days;
for (days = 0; k > 0 || pattern[days % 6][0] == 0; days++) {
for (int i = 0; i < 2; i++) {
k -= pattern[days % 6][i];
}
}
int year, month, day;
int leap = 0;
for (year = 2023; days >= 365 + leap; leap = ++year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
days -= 365 + leap;
}
int monthLengths[13] = {0};
for (int i = 1; i <= 7; i++) {
monthLengths[i] = 30 + i % 2;
}
for (int i = 8; i <= 12; i++) {
monthLengths[i] = 31 - i % 2;
}
monthLengths[2] = 28 + leap;
for (month = 1; days >= monthLengths[month]; month++) {
days -= monthLengths[month];
}
day = days + 1;
printf("%04d/%02d/%02d", year, month, day);
return 0;
}
*/
/*
#include <stdio.h>
#include <stdlib.h>
int stack[100000] = {0};
int queue[100000] = {0};
int codes[100000] = {0};
int stackSize = 0;
int queueFront = 0;
int queueRear = 0;
int n;
void stackPush(int value) {
stack[stackSize++] = value;
}
int stackPop() {
return stack[--stackSize];
}
void stackClear() {
stackSize = 0;
}
int queueEmpty() {
return queueFront == queueRear;
}
int queueSize() {
return queueRear - queueFront;
}
void enqueue(int value) {
queue[queueRear++] = value;
}
int dequeue() {
return queue[queueFront++];
}
int getCodeID(int code) {
for (int i = 1; i <= n; i++) {
if (codes[i] == code) {
return i;
}
}
return 0;
}
int main() {
int k, m;
char c;
scanf("%d %d%*c", &n, &k);
for (int i = 1; i <= n; i++) {
codes[i] = 0;
for (int j = 0; j < k; j++) {
scanf("%c", &c);
codes[i] <<= 1;
codes[i] += c - '0';
}
scanf("%*c");
}
int codeID, code, nextCodeID;
int* previousCode = (int*)malloc(sizeof(int) * (n + 1));
previousCode[0] = -1;
previousCode[1] = -1;
for (int i = 2; i <= n; i++) {
previousCode[i] = 0;
}
enqueue(1);
while (!queueEmpty()) {
codeID = dequeue();
code = codes[codeID];
for (int i = 0; i < k; i++) {
nextCodeID = getCodeID(code ^ 1 << i);
if (previousCode[nextCodeID] == 0) {
enqueue(nextCodeID);
previousCode[nextCodeID] = codeID;
}
}
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &codeID);
while (codeID > 0) {
stackPush(codeID);
codeID = previousCode[codeID];
}
if (stackSize == 1) {
printf("-1");
} else {
while (stackSize > 0) {
printf("%d ", stackPop());
}
}
printf("\n");
stackClear();
}
free(previousCode);
return 0;
}
*/
#include <stdio.h>
#include <stdlib.h>
// 4726. 수열
int main() {
int n, k;
scanf("%d %d", &n, &k);
int* numbers = (int*)malloc(sizeof(int) * n);
for (int i = 0; i < n; i++) {
scanf("%d", &numbers[i]);
}
int* sums = (int*)malloc(sizeof(int) * (n - k + 1));
sums[0] = 0;
for (int i = 0; i < k; i++) {
sums[0] += numbers[i];
}
int max = sums[0];
for (int i = 1; i < n - k + 1; i++) {
sums[i] = sums[i - 1] - numbers[i - 1] + numbers[k + i - 1];
if (sums[i] > max) {
max = sums[i];
}
}
printf("%d", max);
return 0;
}