Source Code
#include <iostream>
#include<algorithm>
#include <cmath>
using namespace std;


int main() {
	long long int t;
	cin >> t;
	long long int n;
	for (int i = 1; i <= t; i++) {
		cin >> n;
		long long int sum = 1;
		int k =n*n;
		for (int j = 1; j < n; j++)
		{
			sum = sum +k;
			k = k-n-1;
		}
		cout << sum << endl;
	}
	
	
	
	return 0;

}
Copy
Ali's Game hoodlum awm
GNU G++17
2061 ms
1.6 MB
Time Limit Exceeded