Given an integer n, find the absolute difference between sum of the squares of first n natural numbers and square of sum of first n natural numbers.

**Input:**

The first line of the input contains a single integer **T**, denoting the number of test cases. Then **T** test case follows, a single line of the input containing a positive integer N.

**Output:**

For each testcase, ** **print the absolute difference between sum of the squares of first n natural numbers and square of sum of first n natural numbers.

**Constraints:**

1<=T<=100

1<=N<=1000

**Example:**

Input:

2

10

5

Output:

2640

170

Explanation: Testcase 2 : N = 5, Sum of 5 natural numbers from 1 to 5 = 15 i.e. 15 *15 = 225.

Sum of squares of numbers from 1 to 5 = 1 + 4 + 9+ 16+ 25 = 55.

So, absolute difference is (225 - 55) = 170.

** **

Author: Sahil_Chhabra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

_Shubham_Jain_06 | 404 |

maggiiiii | 315 |

Savage_19 | 310 |

ritikdagar0203 | 241 |

thanuvinu94 | 233 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 715 |

okayboss | 652 |

maggiiiii | 598 |

Savage_19 | 576 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.