Solve the programming task below in a Python markdown code block.
Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. 

On the day of the party, the Chef was over-seeing all the food arrangements as well, ensuring that every item was in its designated position. The host was satisfied with everything except the cupcakes. He noticed they were arranged neatly in the shape of a rectangle. He asks the Chef to make it as square-like as possible. 

The Chef is in no mood to waste his cupcakes by transforming it into a perfect square arrangement. Instead, to fool the host, he asks you to arrange the N cupcakes as a rectangle so that the difference between the length and the width is minimized. 

------ Input ------ 

The first line of the input file contains an integer T, the number of test cases. Each of the following T lines contains a single integer N denoting the number of cupcakes.

------ Output ------ 

Output T lines, each indicating the minimum possible difference between the length and the width in a rectangular arrangement of the cupcakes.

------ Constraints ------ 

1 ≤ T ≤ 100
1 ≤ N ≤ 10^{8}

----- Sample Input 1 ------ 
4
20
13
8
4
----- Sample Output 1 ------ 
1
12
2
0
----- explanation 1 ------ 
Test case $1$: $20$ cupcakes can be arranged in a rectange in $6$ possible ways -  $1 \times 20, 2 \times 10, 4 \times 5, 5 \times 4, 10 \times 2$ and $20 \times 1$.  
The corresponding differences between the length and the width for each of these rectangles are $ |1-20| = 19, |2-10| = 8, |4-5| = 1, |5-4| = 1, |10-2| = 8$ and $|20-1| = 19$ respectively. Hence, $1$ is the smallest difference between length and width among all possible combinations.

Test case $2$: $13$ cupcakes can be arranged in $2$ ways only. These are $13 \times 1$ and $1 \times 13$. In both cases, the difference between width and length is $12$.

Test case $3$: $8$ cupcakes can be arranged in $4$ ways. These are: $8\times 1, 4\times 2, 2\times 4$ and $1\times 8$. The minimum difference between length and width is $2$ which is in the cases $4\times 2 $ and $2\times 4$.

Test case $4$: $4$ cupcakes can be arranged as $2\times 2$. The difference between the length and the width, in this case, is $0$.