Simple division
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Integer division between a dividend and a divisor yields a quotient and a remainder . is the integer which maximizes such that and .
For any set of integers there is an integer such that each of the given integers when divided by leaves the same remainder.
Input
Each line contains a sequence of nonzero -bit signed integers separated by space. The last number on each line is and this number does not belong to the sequence. There will be at least and no more than numbers in a sequence; not all numbers occurring in a sequence are equal. The last line contains a single and should not be processed.
Output
For each input line, print the largest integer which when divided into each of the input integers leaves the same remainder.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 50%