import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); String s[]=br.readLine().split(" "); int n=Integer.parseInt(s[0]); int k2=Integer.parseInt(s[1]); String c[]=br.readLine().split(" "); int dp[][]= new int[n][n]; for(int l=1;l<=n;l++){ for(int i=0;i k2 && j-k>k2){ dp[i][j] = Math.min(dp[i][j] , dp[i][k-k2-1]+dp[k+k2+1][j] + Integer.parseInt(c[k])); } else if(k-i > k2){ dp[i][j] = Math.min(dp[i][j] , dp[i][k-k2-1] + Integer.parseInt(c[k])); } else if(j-k>k2){ dp[i][j] = Math.min(dp[i][j] , dp[k+k2+1][j] + Integer.parseInt(c[k])); } else{ dp[i][j] = Math.min(dp[i][j] , Integer.parseInt(c[k])); } } } } } /* for(int i=0;i