#C6335. Maximum Sum of Differences Arrangement
Maximum Sum of Differences Arrangement
Maximum Sum of Differences Arrangement
Given an integer N (with N ≥ 2), we consider a "challenge arrangement" where numbers are arranged in such a way that the sum of absolute differences between consecutive elements is maximized. It can be observed that:
- For N = 2, the maximum sum is 2.
- For N = 3, the maximum sum is 4.
- For N \ge; 4, the maximum sum is given by the formula $$2(N-1)$$.
Your task is to compute the maximum sum for each test case provided.
inputFormat
The input begins with an integer T, representing the number of test cases. This is followed by T lines, each containing a single integer N.
outputFormat
For each test case, output a single line containing the maximum sum of absolute differences for the challenge arrangement.## sample
1
2
2