BETA

Difficulty Level:

Easy

Total Submissions: 177 Accuracy:

26.55%

Maximum sum difference
     

Given a number N. We have to find maximum sum of all permutations of numbers from 1 to N. The maximum sum will be sum of absolute difference of adjacent elements in array.

Input:
First line contains an integer T denoting number of test cases. The next T lines contains a single integer N each.


Output:
For each test case, print the maximum sum.
 

Constraints:
1<=T<=100000
1<=N<=1000

Example:
Input:
2
2
3
Output:
1
3

Explanation:
Input : 2
Output : 1

Permutations of 2 are:

{1, 2} = 1

{2, 1} = 1

Input : 3
Output : 3
Permutations of size 3 are:
{1, 2, 3} = 1 + 1
{1, 3, 2} = 2 + 1
{2, 1, 3} = 1 + 2
{2, 3, 1} = 1 + 2
{3, 1, 2} = 2 + 1
{3, 2, 1} = 1 + 1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: ShivamKD

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.