CUTCAKE - Eat all the brownies !

no tags 

BrownieDude was given the job of cutting cake at a party for serving the guests. But BrownieDude is both lazy and hungry, so he wants to cut the cake into maximum number of pieces with minimum number of cuts and go off to eating brownies.

The host of the party says that BrownieDude can cut the cake into unequal pieces but cannot cut in more than one plane. (Only vertical cuts are allowed.) Given the number of guests, find the number of cuts sufficient to generate the cake pieces.

Input

First line contains 't', the number of test cases. 't' lines follow. (1 ≤ t ≤ 1000)

Each line denotes the number of guests. (1 ≤ n ≤ 1011)

Output

One number denoting the number of cuts.

Note: It is guaranteed that an integer solution will always exist.

Example

Input:
2
1
2

Output:
0
1

Explanation for test cases: If there is only one guest, there is no need to cut the cake. If there are 2 guests, the cake can be cut into 2 pieces in 1 cut.


hide comments
Akshay Deep: 2014-08-25 00:44:18

Easy... 12 lines of code in c++ :D

Mayank: 2014-07-02 10:43:38

Nice mathematical problem

Akhil Gupta: 2014-06-30 07:30:49

50th Classical. :D

Diksha Jaiswal: 2014-06-26 12:36:58

my 50th classical :)

ajay verma: 2014-05-24 08:02:46

long will suffice in java .... dont think about BigInteger ...it will give TLE..

Kunal Rout: 2014-03-11 09:44:08

@Pandyan : For 10^11 should the answer be 37?
Can you please check 11226273?

Last edit: 2014-03-11 11:16:32
shivamtripathi: 2014-02-08 07:19:06

AC in 1st go :)

The Alchemist: 2014-01-31 21:35:20

Explored sumthing new :D


Added by:Pandian
Date:2013-12-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All