PUCMM210 - A Summatory

f(n) is defined as: f(n) = 13+23+33+...+n3, so it is the sum of the cubes of all natural numbers up to n.

In this problem you are about to compute,

f(1) + f(2) + f(3) + ... + f(n)

Input

The first line is an integer T (1 ≤ T ≤ 100,000), denoting the number of test cases. Then, T test cases follow.

For each test case, there is an integer n (1 ≤ n ≤ 1,000,000) written in one line.

Output

For each test case output the result of the summatory function described above.

Since this number could be very large, output the answer modulo 1,000,000,003.

Example

Input:
3
2
10
3

Output:
10
7942
46

Added by:Olson Ortiz
Date:2012-05-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Used in 2nd dominican ACM-ICPC Warm Up 2012 Competition in PUCMM

hide comments
2014-08-19 08:46:05 Richa Jain
precomputation helps :)
2014-07-20 12:13:56 « sudipto »
precal with modulo got me AC in 3.30..!!!
2014-07-02 20:25:59 Pratham
y python is getting tle with o(10^6) complexity... :(

Last edit: 2014-07-02 20:35:19
2014-04-26 11:38:40 vinayawsm
@vyanktesh its 418947905 for 10^6
2014-03-17 21:30:26 Vyanktesh Kanungo
plz tell me the correct output for 10^6
mine is 827455.. is it correct?
2014-01-17 14:09:04 Jumpy
how to do it in 1 sec any suggestions
@Tjandra need your help..
2014-01-17 14:04:33 Jumpy
how to do it in 1 sec any suggestions
@Tjandra need your help..
2014-01-12 20:01:42 Samil Vargas
the answer for 10^6 is 418947905

Last edit: 2014-01-14 12:15:40
2014-01-12 18:42:40 Samil Vargas
plz anybody whats the answer in 1000000 ?

Last edit: 2014-01-12 19:51:28
2013-12-05 16:08:08 Saimadhav Heblikar
learnt a lot on this prob
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.