시간 제한
메모리 제한

The lock comes with three code numbers T1, T2, T3. These are non-negative integers and each of them is less than N. No two of the three are the same.
The lock is opened in three stages of operations:
You must find the maximum possible number of ticks the dial must be turned in order to open the lock. The number of ticks turned is defined to be the sum of the ticks turned in the three stages outlined above, and is always positive regardless of direction.
The input file consists of a number of test cases, one test case per line. Each line of the input file contains four integers: N, T1, T2, T3, in this order, separated by blank spaces. The integer N is a multiple of 5, 25 <= N <= 100. The numbers T1, T2 and T3 satisfy the constraints stated under the description above. The input will be terminated by a line with four blank-separated 0’s.
For each test case, print the maximum possible number of ticks the dial must be turned in order to open the lock. Print each on its own line. There should be no blank lines between outputs.