Time limit
2s
Memory limit
128 MB
Sejun works at a library. After closing time, he must return books that people left out of place to their original positions.
Sejun starts at coordinate 0, and all books are initially at coordinate 0. Given the original integer coordinate of each book, compute the minimum number of steps needed to put every book back.
Sejun moves by 1 coordinate per step. After placing all books, he does not need to return to coordinate 0. He can carry at most M books at once.
The first line contains N, the number of books, and M, the maximum number of books Sejun can carry at once.
The second line contains the original positions of the books. N and M are natural numbers at most 50. Every position is nonzero, and its absolute value is an integer at most 10,000.
Print the minimum number of steps on the first line.