/* -*- coding: utf-8 -*- * * 1824.cc: No.1824 門\松\列 - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ inline ll sigma(int n) { return (ll)n * (n + 1) / 2; } inline ll sigma2(int n) { return (ll)n * (n + 1) * (2 * n + 1) / 6; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); // sum_{i=1..n} { sum_{j=i+1..n} (j-2) + sum_{j=1..i-1} (n-j-1) } // = sum_{i=1..n} {(sigma(n)-sigma(i)-2(n-i)) + ((i-1)*n-sigma(i-1)-(i-1))} // = sum_{i=1..n} (sigma(n)-sigma(i)-2(n-i)+(i-1)(n-1)-sigma(i-1)) // = sum_{i=1..n} (sigma(n)-2(n-i)+(i-1)(n-1)-i(i+1)/2-(i-1)i/2) // = sum_{i=1..n} (sigma(n)-2n+2i+(n-1)i-(n-1)-i^2) // = sum_{i=1..n} (sigma(n)-i^2+(n+1)i-(3n-1)) // = n*sigma(n)-sigma2(n)+(n+1)sigma(n)-n*(3n-1) // = (2n+1)sigma(n)-sigma2(n)-n(3n-1) ll sum = sigma(n) * (n * 2 + 1) - sigma2(n) - (ll)n * (n * 3 - 1); printf("%lld\n", sum); } return 0; }