UVa 10550

Determine how many degrees a combination lock would rotate.

Explanation
There's three full circle rotations, and extra distance is from the difference between the combination numbers.

Gotchas

 * The movement from the initial position to the first number is clockwise. With this combination lock, clockwise turn causes the number to decrease. (This is only understood if looking at the image in the problem.)

Implementations
distance = 1080 + ( (start-first+40) % 40 + (second-first+40)%40 + (second - third+40)%40) * 9

Input
0 30 0 30 5 35 5 35 0 20 0 20 7 27 7 27 0 10 0 10 9 19 9 19 0 0 0 0

Output
1350 1350 1620 1620 1890 1890