import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
Scanner in
= new Scanner
(System.
in); int n = in.nextInt(); int k = in.nextInt();
// массивы для времени каждого мероприятия и потраченного времени;
int[] stairs= new int[n + 1]; int[] time= new int[n + 1];
for(int i = 1; i < n + 1; ++i) {
stairs[i] = in.nextInt();
if (i <= k + 1) time[i] = stairs[i];
}
time[0] = 0;
for(int i = 2; i <= n; ++i) {
if (i > k + 1) time[i] = time[i - 1] + stairs[i]; //начальный минимум;
for(int j = 2; j <= k+1; ++j) {
// выбор минимально затраченного времени;
if (i
- j
>= 0) time
[i
] = Math.
min(time
[i
- j
] + stairs
[i
], time
[i
]); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBuID0gaW4ubmV4dEludCgpOyBpbnQgayA9IGluLm5leHRJbnQoKTsKCQkvLyDQvNCw0YHRgdC40LLRiyDQtNC70Y8g0LLRgNC10LzQtdC90Lgg0LrQsNC20LTQvtCz0L4g0LzQtdGA0L7Qv9GA0LjRj9GC0LjRjyDQuCDQv9C+0YLRgNCw0YfQtdC90L3QvtCz0L4g0LLRgNC10LzQtdC90Lg7CgkJaW50W10gc3RhaXJzPSBuZXcgaW50W24gKyAxXTsgaW50W10gdGltZT0gbmV3IGludFtuICsgMV07IAoJCWZvcihpbnQgaSA9IDE7IGkgPCBuICsgMTsgKytpKSB7CgkJCXN0YWlyc1tpXSA9IGluLm5leHRJbnQoKTsgCgkJCWlmIChpIDw9IGsgKyAxKSB0aW1lW2ldID0gc3RhaXJzW2ldOwoJCX0KCQl0aW1lWzBdID0gMDsgC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