AFS - Amazing Factor Sequence

Bhelu is the classmate of Bablu who made the Amazing Prime Sequence.

He felt jealous of his classmate and decides to make his own sequence. Since he was not very imaginative, he came up with almost the same definition just making a difference in f(n):

  • a[0] = a[1] = 0.
  • For n > 1, a[n] = a[n - 1] + f(n), where f(n) is the sum of positive integers in the following set S.
  • S = {x | x < n and n % x = 0}.

Now, Bablu asked him to make a code to find f(n) as he already had the code of his sequence. So, Bhelu asks for your help since he doesn't know programming. Your task is very simple, just find a[n] for a given value of n (< 10^6).

Input

Your code will be checked for multiple test cases.

First Line of Input contains T (<= 100), the number of test cases.

Next T lines contain a single positive integer N. (1 < N < 10^6).

Output

Single line containing a[n] i.e. n-th number of the sequence for each test case.

Example

Input:
3
3
4
5

Output:
2
5
6

Explanation

f(2) = 1 {1}
f(3) = 1 {1}
f(4) = 3 {1, 2}
f(5) = 1 {1}

Added by:c[R]@zY f[R]0G
Date:2013-03-15
Time limit:1s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2020-04-13 14:32:55
Precomputation is just Amazing :D
2018-10-06 14:57:19
little modification in sieve algorithm
2018-05-18 23:02:25
Little modification to sieve will work :)

Last edit: 2018-05-18 23:12:51
2017-07-24 10:37:34
finally 100th.. :)
2017-07-05 18:44:24
try to solve in O(n) otherwise TLE, precalculation is required
2016-07-20 19:35:44
this problem is easy if u r not overconfident...please focus more on problem statement

Last edit: 2016-07-20 19:36:13
2016-06-14 19:24:06
@Ankit got accepted after declaring array globally. Thanks!
2016-02-10 18:00:06
modify sieve and you are done !!!!
2016-01-31 14:25:49 GAURAV CHANDEL
I love precalculations....
2015-09-17 19:28:33 shantanu tripathi
o(n) also got accpted...hehe
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.