n, k = map(int, input().strip().split()) costs = list(map(int, input().strip().split())) r, m = divmod((n-1),(2*k+1)) r += 1 q = k+1-abs(m-k) nodes = [] for i in range(m): if (m-k > 0): nodes.append(k-i) else: nodes.append(i) best = 0 for i in range(r): best += costs[i+nodes[0]] for j in nodes[1:]: total = 0 for i in range(r): total += costs[i+j] if (total < best): best = total print(best)