Source Code
#include <iostream>


using namespace std;
int main() {
int t ; 
  cin>>t;
  
  
  while(t--)
    {
      int sum = 0 ;
      int n ;
      cin>>n; 
      
      
      for(int i =1 ; i<n ; i++)
        { sum += (i-1)*n+i+1;
          
          }
      sum+= (n-1)*n+1;
      cout<<sum<<endl;
      
    }
  

}
Copy
Ali's Game Tala_Ibraheem
GNU G++17
2087 ms
1.2 MB
Time Limit Exceeded