ESQU - Easy Equation

There is an equation for you:

    A MOD B = C, where A > B

What is the maximum value of C when B is given?

Input

Input starts with an integer T (≤ 100) denoting the number of test cases.

Each test case contains a number B (2 <= B <= 10100000).

Output

For each case, output the expected result.

Example

Input:
4
2
15
1005
365

Output:
1
14
1004
364

Problem Setter: Ajharul Islam Barid. Special Thanks: Shipu Ahamed


Added by:Alim
Date:2014-08-13
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2017-03-21 05:52:11
Java BigInteger Got TLE
ad-hoc problem

Last edit: 2017-03-21 05:53:16
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.