PandeyG, a brilliant tennis player, decided to start a tournament in his colony. Now, since PandeyG is overly optimistic and ambitious - he tries to lure in as many people as he can from his colony for them to participate in his very own knockout type tennis tournament. What he fails to realize that, to have a knockout tournament, you need to have number of players, in the form of 2^a, where a is any number - what it simply means is that, if there are only 7 people to take part in the tournament, a knockout version cannot be held. 

Because:
1 vs. 2 |
3 vs. 4 | 
5 vs. 6 | 
7 vs. ? |

So, he comes with a brilliant algorithm of adding ghost opponent, to make his tournament more popular. So, for every player who is short of an opponent, he will face a ghost - matches between the ghosts, and matches between ghosts and players are not counted, of course. So, basically, the player who gets the ghost opponent gets a free bye to the next round, i.e., he qualifies for the next round, without even facing an opponent. If there are no players, there will obviously be no matches.

So, given the number of players willing to take part, can you help PandeyG figure out the number of matches he will have to make arrangements for?

Input Format:
On the first line, the number of test cases are given, then following every line, the number of players who want to participate n is given.

Output Format:
For every n, output the number of matches which will be played for the tournament to be held, by our PandeyG.

Constraints:

t ≤10

0 ≤ n ≤ 10^9SAMPLE INPUT
2
7
3

SAMPLE OUTPUT
6
2

Explanation

For n = 7,
1 v 2 - 1
3 v 4 - 2
5 v 6 - 3
7 v ? 
-
1 v 3 - 4
5 v 7 - 5
-
1 v 7 - 6

So, 6 matches will need to be played!
name=int(raw_input( ))
while(name>0):
	n=int(raw_input())
	if(n!=0):
		print n-1
	else:
		print 0
	name=name-1