using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { var arr = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); n = arr[0]; k = arr[1]; costs = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); long result = MinCost(new bool[n], -1); Console.WriteLine(result); } static long MinCost(bool[] isOff, int lastOff){ if (isOff.All(c => c)){ return 0; } long best = long.MaxValue; for(int i=1; i <= 2*k+1; i++){ int trial = lastOff + i; if(trial < n){ long curr = costs[trial]; if (curr < best){ curr += MinCost(TurnOff(trial, isOff), trial); best = Math.Min(best, curr); } } } return best; } static bool TurnsOffAny(int s, bool[] arr){ for(int i=s; i>=0 && i>=(s-k); i--){ if (!arr[i]){ return true; } } for(int i=s; i=0 && i>=(s-k); i--){ result[i] = true; } for(int i=s; i