output_description: Print the minimum possible total cost incurred.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      h_1 h_2 \ldots h_N
attempt: n, k = map(int, input().split())                                         |n = int(input())
  h = list(map(int, input().split()))                                      |h = list(map(int, input().split()))
  dp = [0] * n                                                             |dp = [0]*n
                                                                           |
  for i in range(n):                                                       |for i in range(n):
      if i == 0:                                                           |    if i == 0:
          dp[0] = 0                                                        |        dp[0] = 0
      elif i == 1:                                                         |    elif i == 1:
          dp[1] = abs(h[0]-h[1])                                           |        dp[1] = abs(h[0]-h[1])
      else:                                                                |    else:
          costs = []                                                       |        cost1 = dp[i-1] + abs(h[i-1]-h[i])
          for j in range(1, k+1):                                          |        cost2 = dp[i-2] + abs(h[i-2]-h[i])
              if j > i:                                                    |        dp[i] = min(cost1, cost2)
                  break                                                    |
              if abs(h[i-j]-h[i]) == 0:                                    |print(dp[n-1])
                  costs.append(dp[i-j])                                    |
                  break                                                    |
              costs.append(dp[i-j] + abs(h[i-j]-h[i]))                     |
                                                                           |
          # if i == 3:                                                     |
          #     print(costs)                                               |
          dp[i] = min(costs)                                               |
                                                                           |
  #print(dp)                                                               |
  print(dp[n-1])                                                           |
                                                                           |
  
problem_description: Statement
  
  There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N),
  the height of Stone i is h_i.
  
  There is a frog who is initially on Stone 1. He will repeat the following
  action some number of times to reach Stone N:
  
    * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on.
  
  Find the minimum possible total cost incurred before the frog reaches Stone N.
samples: [{"input": "5 3\n    10 30 40 50 20", "output": "30\n    \n\nIf we follow the path 1 \u2192 2 \u2192 5, the total cost incurred would be |10 - 30| +\n|30 - 20| = 30.\n\n* * *"}, {"input": "3 1\n    10 20 10", "output": "20\n    \n\nIf we follow the path 1 \u2192 2 \u2192 3, the total cost incurred would be |10 - 20| +\n|20 - 10| = 20.\n\n* * *"}, {"input": "2 100\n    10 10", "output": "0\n    \n\nIf we follow the path 1 \u2192 2, the total cost incurred would be |10 - 10| = 0.\n\n* * *"}, {"input": "10 4\n    40 10 20 70 80 10 20 70 80 60", "output": "40\n    \n\nIf we follow the path 1 \u2192 4 \u2192 8 \u2192 10, the total cost incurred would be |40 -\n70| + |70 - 70| + |70 - 60| = 40."}]