Activating Robots
문제
You and a single robot are initially at point on a circle with perimeter (). You can move either counterclockwise or clockwise along the circle at unit per second. All movement in this problem is continuous.
Your goal is to place exactly robots such that at the end, every two consecutive robots are spaced away from each other (, divides ). There are () activation points, the th of which is located distance counterclockwise from (). If you are currently at an activation point, you can instantaneously place a robot at that point. All robots (including the original) move counterclockwise at a rate of unit per seconds ().
Compute the minimum time required to achieve the goal.
입력
The first line contains , , , and .
The next line contains space-separated integers .
출력
The minimum time required to achieve the goal.
예제
예제 1
10 2 1 2 6
22
예제 2
10 2 1 2 7
4
예제 3
32 4 5 2 0 23 12 5 11
48
예제 4
24 3 1 2 16
48