Source Code
#include<iostream>
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 sum = n * (n + 1) / 2 + n * (n * (n - 1) / 2);
		cout <<sum << endl;
	}
	
	
	
	return 0;

}
Copy
Ali's Game hoodlum awm
GNU G++17
226 ms
2.8 MB
Accepted