def getCost(ON, C, K): # print(ON) if sum(ON) == 0: return 0 costs = [] for n in range(len(ON)): if ON[n] == 1: NEW = ON[:] for a in range(-K, K+1): if n+a > -1 and n+a < len(ON): NEW[n+a] = 0 costs.append(C[n] + getCost(NEW, C, K)) return min(costs) N, K = [int(n) for n in input().split()] C = [int(n) for n in input().split()] ON = [1]*N print(getCost(ON, C, K))