Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

    ios_base::sync_with_stdio(0);
    cout.tie(0); cout.tie(0);

    int tt;
    cin >> tt;
    while(tt--)
    {
        ll n;
        cin >> n;
        cout << n + (n * (n - 1) / 2) * (n + 1) << '\n';
    }
    return 0;
}
Copy
Ali's Game Greedious
GNU G++17
288 ms
2.2 MB
Accepted