n,k = map(int,input().split()) c = list(map(int,input().split())) if n-1 <= 2*k: print(min(c[-k-1:k+1])) elif k: print(sum(q for q in c[k::k])) else: print(sum(c))