TRICOUNT - Counting Triangles


We define the LEVEL of a triangle as in the following illustrative image:

Task: Your task is very easy. All you have to do is to count all triangles in the biggest one (Level N).

Input

The first line of the input contains an integer T (T ≤ 10000) - the number of test cases and T lines follow. Each line contains an integer N (1 ≤ N ≤ 106) which is the level of the triangle in that test case.

Output

For each test case, you should write a seperate line: the number of triangles in the biggest one (Level N). (All answers will fit within the range of a 64-bit integer)

Example

Input:
3
1
2
3

Output:
1
5
13

Source limit is 500 bytes.


hide comments
blackhat_130: 2020-03-27 22:19:48

use long long also during accepting input than only in writing answer otherwise you'll get wrong answer.
This error costs me 3 wrong submission.

Last edit: 2020-03-27 22:21:13
aryan__0406: 2020-03-20 19:55:10

Nothing is impossible friends,use your mind and solve this problem. I am also trying this problem from the previous one year and i am confident that one day i will be able to solve this problem efficiently.

savage_19: 2020-02-05 08:17:35

Use long data type.. costed many WAs.

rushout09: 2019-09-12 17:38:58

This video will help you understand the concept:
https://www.youtube.com/watch?v=9EU3FlKj-3M

quannguyenlhp: 2019-08-12 11:02:59

Don't use the formula, try to come up with another solution less than 500b, it's more challenge.

Last edit: 2019-08-12 11:03:26
hetp111: 2019-05-24 21:59:35

For those who think 4th level should be 3rd level... here we are adding 2n-1 triangles to the base of n-1th level to find the nth level, so nth_lvl=(n-1)th_lvl + (2n-1)smalltrianglesOnBase

Last edit: 2019-05-24 22:02:33
klmo: 2019-04-26 16:31:12

Whats the deal with the source code size limit!!!

knir0103: 2019-03-20 08:54:34

can calculate upwards and downwards separately, not necessarily using formula :)

rahul11197: 2019-03-19 12:49:39

ans=ceil ( (n*(n+2)*(2*n+1) ) / 2 )

vaibhav18_: 2019-01-01 16:30:53

easy one if u know the formula
else awake the programmer and challenge yourself...;p


Added by:nha.duong
Date:2007-08-05
Time limit:1s
Source limit:500B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 ERL JS-RHINO NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Trần Huy Hưng