Sum of Subrectangle Areas

For each N, compute the total area of all axis-aligned integer subrectangles in an N by N grid.

Easy3MathCombinatoricsNo attempts yetTime limit2sMemory limit512 MB

Problem

Consider the grid from (0,0)(0, 0) to (N,N)(N, N).

Consider every subrectangle whose four corners have integer coordinates, that is, every [r1,r2]×[c1,c2][r_1, r_2] \times [c_1, c_2] with 0r1<r2N0 \le r_1 < r_2 \le N and 0c1<c2N0 \le c_1 < c_2 \le N. The area of such a rectangle is (r2r1)×(c2c1)(r_2 - r_1) \times (c_2 - c_1). The following pseudocode computes the sum of the areas of all subrectangles.

sum = 0
for r1 = 0 to N-1
  for c1 = 0 to N-1
    for r2 = r1+1 to N
      for c2 = c1+1 to N
        sum = sum + (r2-r1)*(c2-c1)
print(sum)

Given NN, compute this sum efficiently. The input contains several test cases.

Input

The first line contains the number of test cases TT. Each of the following TT lines contains a single integer NN for that test case. NN fits in a 64-bit integer with 0N92233720368547758070 \le N \le 9223372036854775807.

Output

For each test case, print the sum defined above on its own line. The sum may exceed the range of a 64-bit integer, so print it as an arbitrary precision integer.