Source Code
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long long int ll;

ll mod=1e9+7;
ll a[200010];
ll b[200010];
ll tc,i,j,k,n,m,x;
string s,s1,s2;

vector< pair<ll,ll> > v;

int main(){

    IOS

    cin>>tc;

    while(tc--){

            cin>>n;

            ll ans=0;

            ll j=1;

            for(i=1;i<=n;i++){
                ans+=(i-1)*n+j;

                j++;
            }

            cout<<ans<<endl;

    }

}
Copy
Ali's Game AshcoOoOdel
GNU G++17
2058 ms
1.5 MB
Time Limit Exceeded