#include #include #include #include #include using namespace std; #define inf 1000000000000000LL long long dp[10010], c[10010]; int main() { // freopen("test.in", "r", stdin); int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> c[i]; } long long best = inf; for (int i = 1; i <= min(n, k+1); ++i) { int last = 0; long long sum = 0; for (int j = i; j <= n; j += 2*k+1) { last = j; sum += c[j]; } if (last + k >= n) { best = min(best, sum); } } cout << best; }