There is a line of
In addition, to get from index
Constraints
For all subtasks:
- There is always at least one box with
for all .
Points Awarded | |
---|---|
5 points | |
10 points |
Input Specification
The first line contains two integers
The second line contains
Output Specification
Output the minimum distance required. Please note that this number may not fit inside a 32-bit integer.
Sample Input
4 3
3 1 2 2
Sample Output
5
Explanation for Sample Output
Starting from index
Comments