MEHUL & SATELLITES

All submissions for this problem are available.
Problem description.
Mehul is working at some international space organization center which makes and launches the satellites into the orbits.Space center is currently working on some secret missions and has recently manufactured N number of satellites of different heights given by the range [1,R] (height of first satellite is 1 and last satellite is R).
Mehul has given a task in which, All the newly manufactured N number of satellites of different heights has to be arranged in a specific order.At present mehul is a part of multiple missions.So he has asked for your help.Your task is to arrange the N satellites according to their heights such as the total sum S of differences of heights of adjacent satellites is maximum.
consider the difference between the heights of two adjacent satellites as  hi  (hi+1) , which always be a positive number.
Input
The first line of the input contains total number of test cases T.
Each test case contains one integer R ,which defines the range [1,R] of heights of satellites.
Output
For each test case output the single integer S which defines total maximum sum as mentioned in the statement.
Constraints
 0 < T ≤ 10000
 1 < R ≤ 100000
Example
Input: 2 3 2 Output: 3 1
Explanation
Case 1.
R=3, i.e [1,3] heights of satellites are 1,2,3.
total 3 heights are given that means total 3 satellites are present. i.e N=3
height of 1st satellite is 1 and so on.
we can arrange the satellites by their heights into the following possible ways.
[1,2,3]
[1,3,2]
[2,1,3]
[2,3,1]
[3,1,2]
[3,2,1]
Total sum of differences of heights of adjacent satellites for arrangement [1,2,3] is 2. i.e abs(12)+abs(23)=2
Similarly,
for [1,3,2] is 3.
for [2,1,3] is 3.
for [2,3,1] is 3.
for [3,1,2] is 3.
for [3,2,1] is 2.
The maximum value of S is 3.
Author:  mehul_dholiya 
Editorial  https://discuss.codechef.com/problems/SUSMD 
Tags  cfea2018, easymedium, maths, mehul_dholiya 
Date Added:  9022018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions