Source Code
#include<bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;


int main()
{

    FAST;
  ll t; cin>>t;

  while(t--){
    ll sum=0;
    ll n ;cin >>n;
    for (int i=1,j=1;i<=n;i++,j++){
        sum+=(i-1)*n+j;
    }
    cout <<sum<<endl;
  }


}
Copy
Ali's Game midoelkhaitb
GNU G++17
2089 ms
1.3 MB
Time Limit Exceeded