Source Code
#include <iostream>

using namespace std;

int main()
{
    int n;cin>>n;
    while(n--){
        long long x;cin>>x;
        long long  z=x*(x+1)/2;
        long long  c=(x-1)*(x)/2;
        c*=x;
        cout<<z+c<<'\n';

    }

    return 0;
}
Copy
Ali's Game mohamed
GNU G++17
319 ms
2.2 MB
Accepted