import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); long cost[] = new long[n]; for (int i = 0; i < n; i++) { cost[i] = sc.nextLong(); } int full = 2*k + 1; int remainder = (n % full) + 2*k + 1; long result = Long.MAX_VALUE; for (int j = k; j + k <= remainder; j++) { long counter = 0; int c = j; while (c < cost.length) { counter += cost[c]; c += full; } if (counter < result) {result = counter;} } System.out.println(result); } }