Source Code
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long n;
        cin>>n;
        cout<<n * (n+1)/2 + n*(n*(n-1)/2)<<endl;
    }
}
Copy
Ali's Game moathhamudah
GNU G++17
257 ms
2.9 MB
Accepted