Xiaoming is a little boy.
One day, he finds a

grids on his school's playground. For each grid, there is am integer between

and

written on it.
His classmate invites him to play with the grids. His task is to jump on the grids one by one. The first step he should stand on the grid in which number

is written (any one is ok), then he has to jump onto one of the grids with number

written on it, then he has to jump onto the grids with number

, and so on, until he jumps onto the grid with number

.
The cost of jumping from grid
)
to
)
is the Manhattan distance between them, that is,

.
Xiaoming wonders if he can finish the task. If so, what is the minimum total cost to finish the task?