#D2301. Soccer
Soccer
Soccer
You are a manager of a prestigious soccer team in the JOI league.
The team has players numbered from 1 to . The players are practicing hard in order to win the tournament game. The field is a rectangle whose height is meters and width is meters. The vertical line of the field is in the north-south direction, and the horizontal line of the field is in the east-west direction. A point in the field is denoted by () if it is -meters to the south and meters to the east from the northwest corner of the field.
After the practice finishes, players must clear the ball. In the beginning of the clearance, the player () stands at (). There is only one ball in the field, and the player 1 has it. You stand at () with the player . The clearance is finished if the ball is passed to (), and you catch it. You cannot move during the clearance process.
You can ask players to act. But, if a player acts, his fatigue degree will be increased according to the action. Here is a list of possible actions of the players. If a player has the ball, he can act (i),(ii), or (iii). Otherwise, he can act (ii) or (iv).
- (i) Choose one of the 4 directions (east/west/south/north), and choose a positive integer . Kick the ball to that direction. Then, the ball moves exactly p meters. The kicker does not move by this action, and he loses the ball. His fatigue degree is increased by .
- (ii) Choose one of the 4 directions (east/west/south/north), and move 1 meter to that direction. If he has the ball, he moves with it. His fatigue degree is increased by regardless of whether he has the ball or not.
- (iii) Place the ball where he stands. He loses the ball. His fatigue degree does not change.
- (iv) Take the ball. His fatigue degree does not change. A player can take this action only if he stands at the same place as the ball, and nobody has the ball.
Note that it is possible for a player or a ball to leave the field. More than one players can stand at the same place.
Since the players just finished the practice, their fatigue degrees must not be increased too much. You want to calculate the minimum possible value of the sum of fatigue degrees of the players for the clearance process.
Example
Input
6 5 1 3 6 3 1 1 0 4 6 5
Output
26
inputFormat
Input
6 5 1 3 6 3 1 1 0 4 6 5
outputFormat
Output
26
样例
6 5
1 3 6
3
1 1
0 4
6 5
26