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 ≤ 10^{6}) 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 64bit integer)
Example
Input:
3
1
2
3
Output:
1
5
13
Source limit is 500 bytes.
hide comments
summer_2:
20180523 19:14:11
explain the solution please?


shubham31:
20180511 12:08:29
(n^2) + [ (n(n1)/2] * [(3+(2*n  1))/6], shows wrong answer... cross checked it. still no success.


riyadhrazzaq:
20180324 18:25:35
There's two version of the formula. One uses floor function , another uses oddeven condition. I've used both of them and only got AC for oddeven condition. Can anybody explain that ? 

kkislay20:
20180310 08:58:48
Use the direct formula...and long long int and you are good to go.


bradyawn:
20180124 00:15:38
For those who are wondering why n = 3 is not 9, it is because triangle of not size 1 also count 

srjsunny:
20180123 14:37:20
use P and C you will get triangles=n(n+2)(2n+1)/8 

vikramvarun:
20180112 11:07:58
SPOJ is the worst platform to practice coding. Gives TLE in R for simple operations as well. Do the admins/moderators do any work at all? Can't they see that time limit should be adjusted according to language. 

arul_verman:
20171227 10:23:03
use long long int and the formula! Perfect AC ;) 

imshreyas:
20171224 13:14:16
Please make use of long long int to avoid a WA even after using the correct formula 

pratikshit:
20171022 08:50:36
only knowing the formula is enough for AC 
Added by:  nha.duong 
Date:  20070805 
Time limit:  1s 
Source limit:  500B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 ERL JSRHINO NODEJS OBJC PERL6 SQLITE VB.NET 
Resource:  Trần Huy Hưng 