Problems
Being a fan of contemporary architecture, Farmer John has built a new barn in the shape of a perfect circle. Inside, the barn consists of a ring of
Farmer John wants exactly
Problem credits: Brian Dean
Input
The first line of input contains
Output
Please write out the minimum amount of distance the cows need to travel.
Example
6 2
2
5
4
2
6
2
14
Farmer John can unlock doors 2 and 5. 11 cows enter at door 2 and walk a total distance of 8 to get to rooms 2, 3, and 4. 10 cows enter at door 5 and walk a total distance of 6 to get to rooms 5, 6 and 1.