Apple Catching Game

Time limit1sMemory limit128 MB

Problem

Sanggeun is playing an arcade game where he moves a basket to catch apples. The screen is divided into N cells from left to right. At the bottom of the screen, a basket occupies M consecutive cells. Initially, the basket occupies the leftmost M cells. During the game, the basket can move left or right, but it cannot move outside the screen.

Apples fall from the top of the screen one at a time. Each apple starts above one given cell and falls straight down to the bottom of that same cell. As soon as one apple reaches the bottom, the next apple starts falling.

If the basket occupies the cell where an apple falls, the basket catches that apple. Find the minimum total distance the basket must move to catch every apple.

Input

The first line contains N, the number of screen cells, and M, the basket size. (1 ≤ M < N ≤ 10)

The second line contains J, the number of falling apples. (1 ≤ J ≤ 20)

Each of the next J lines contains one apple position, in the order the apples fall.

Output

Print the minimum total distance the basket must move to catch every apple.