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

hide comments
Richa Jain: 2014-08-19 08:46:05

precomputation helps :)

« sudipto »: 2014-07-20 12:13:56

precal with modulo got me AC in 3.30..!!!

Pratham: 2014-07-02 20:25:59

y python is getting tle with o(10^6) complexity... :(

Last edit: 2014-07-02 20:35:19
vinayawsm: 2014-04-26 11:38:40

@vyanktesh its 418947905 for 10^6

Vyanktesh Kanungo: 2014-03-17 21:30:26

plz tell me the correct output for 10^6
mine is 827455.. is it correct?

Jumpy: 2014-01-17 14:09:04

how to do it in 1 sec any suggestions
@Tjandra need your help..

Jumpy: 2014-01-17 14:04:33

how to do it in 1 sec any suggestions
@Tjandra need your help..

Samil Vargas: 2014-01-12 20:01:42

the answer for 10^6 is 418947905

Last edit: 2014-01-14 12:15:40
Samil Vargas: 2014-01-12 18:42:40

plz anybody whats the answer in 1000000 ?

Last edit: 2014-01-12 19:51:28
Saimadhav Heblikar: 2013-12-05 16:08:08

learnt a lot on this prob


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