import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { PrintWriter output = new PrintWriter(System.out); new Solution().processInput(new Scanner(System.in), output); output.flush(); } public void processInput(Scanner in, PrintWriter output) { int n = in.nextInt(); // int k = in.nextInt(); int[] costs = new int[n]; for (int i = 0; i < n; i++) { costs[i] = in.nextInt(); } output.println(minCost(n, k, costs)); } private long minCost(int n, int k, int[] costs) { boolean[] on = new boolean[n]; long cost = 0; for (int i = 0; i < n;) { int minCost = Integer.MAX_VALUE; int minIndex = 0; for (int j = i; j <= i + k && j