Stopping Doom’s Day

So! The time of the universe is up and it is the dooms day after five hours :-P, and you must stop it. But to do so you have to know the value of the following expression T :  ∑n ∑n ∑n ∑n ∑n T = Because the secret code that will save the universe from being doomed have something to do with |(|i−j|∗|j−k|∗|k−l|∗|l−m|∗|m−i|)|%10007 the value of the above expression for some value of n. i=1 j=1 k=1 l=1 m=1 Input The input file contains 1000 lines of inputs. Each line contains a single integer n (0 < n ≤ 2000000000). A line containing a single zero terminates input. Output For each line of input produce one line of output. This line contains the value of T. Sample Input 12 20 1001 0 Sample Output 2199 803 2390