Source Code
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <math.h>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int t, n;
	long long ans;
	cin >> t;
	while (t--) {
		cin >> n;
		ans = (n * (n + 1)) / 2;
		ans += n * ((n * (n - 1)) / 2);
		cout << ans << endl;
	}
	return 0;
}






Copy
Ali's Game Sarah
GNU G++17
301 ms
1.3 MB
Wrong Answer