Source Code
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;


int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		int i = 1;
		long long sum = 0;
		while( i <= n){
			sum += (i-1)*n+i;
			i++;
		}
		
		cout << sum << endl;
	}
	return 0;
}
Copy
Ali's Game MohaDarkness
GNU G++17
2075 ms
1.3 MB
Time Limit Exceeded