#include using namespace std; typedef long long int ll; const int NMax = 5e5 + 5; const int LIM = 1e9; int v[10005]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) cin >> v[i]; ll total, ans; ans = INFINITY; for(int i = 1; i <= m + 1; i++){ total = 0; int j; for(j = i; j <= n; j += 2 * m + 1) total += v[i]; if(j - 2 * m - 1 < n - m) total = INFINITY; ans = min(ans, total); } cout << ans; return 0; }