#QHD0000002. Ếch 2 (Frog 2)

Ếch 2 (Frog 2)

Frog 2

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN stones with heights hih_i. From stone ii, the frog may jump to any of i+1,…,i+Ki+1,\ldots,i+K. A jump from ii to jj costs ∣hi−hj∣|h_i-h_j|. Find the minimum cost from stone 1 to stone NN.

Input

Line 1 contains NN and KK. Line 2 contains NN integers h1,…,hNh_1,\ldots,h_N.

Output

Print the minimum total cost.

Subtasks

  • Subtask 1 — 20 points: 2 <= N <= 20; 1 <= K <= 5.
  • Subtask 2 — 30 points: 2 <= N <= 2000; 1 <= K <= 30.
  • Subtask 3 — 50 points: 2 <= N <= 100000; 1 <= K <= 100; 1 <= h_i <= 10000.

Examples

Input

5 3
10 30 40 50 20

Output

30

Explanation

The route 1→2→51\to2\to5 costs 20+10=3020+10=30, and no cheaper route exists.