There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's starting point is a vertex of this cuboid, and she wants to arrive at the opposite vertex. The opposite vertex means the vertex which has no common planes or edges with the starting point. Just like the picture below:
![mtz9548_ant_pic1.gif](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=mtz9548_ant_pic1.gif)
Input
The first line of input contains an integer T(T ≤ 100) . T is the number of the cases. In the following T lines, there are a positive integer n(1≤n≤1014) in each line. n is the longest edge of the cuboid.
Output
For each test case, output the sum of L2 for every possible cuboid in a line. L is the length of shortest path of a cuboid. It may be very large, so you must output the answer modulo 1000000007.
Sample Input
2 3 4
Sample Output
160 440
Hint
(3,2,1) and (3,1,2) are regrad as the same cuboids.Author: MU, Tongzhou
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main
{
public static void main(String args[])
{
BigInteger M = BigInteger.valueOf(1000000007);
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t!=0)
{
t--;
BigInteger n = cin.nextBigInteger();
BigInteger ping = n.multiply(n);//n*n
BigInteger tmp = n.multiply(n.add(BigInteger.valueOf(1)));//n*(n+1)
BigInteger sum = tmp.divide(BigInteger.valueOf(2));//n*(n+1)/2
BigInteger temp = tmp;//n*(n+1)
tmp = n.multiply(BigInteger.valueOf(2));//2n
tmp = tmp.add(BigInteger.valueOf(1));//2n+1
temp = temp.multiply(tmp);//n*(n+1)*(2n+1)
temp = temp.divide(BigInteger.valueOf(6));//n*(n+1)*(2*n+1)/6
tmp = sum.multiply(sum.multiply(BigInteger.valueOf(2)));//sum*sum*2
BigInteger sub = temp.multiply(BigInteger.valueOf(4));//n*(n+1)*(2*n+1)/6*4
sub = sub.add(ping.multiply(n));//n*(n+1)*(2*n+1)/6*4 + ping*n
temp = temp.multiply(n.multiply(BigInteger.valueOf(2)));//n*(n+1)*(2*n+1)/6*(2*n)
BigInteger ans = temp.add(tmp.add(sub.add(ping.multiply(ping))));
ans = ans.divide(BigInteger.valueOf(2));
System.out.println(ans.mod(M));
}
}
}