LUFA cup 2024

LUFA cup 2024

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 256.0 MB

Description

The president of LUFA (Leading university football association) has announced a football tournament named "LUFA cup 2024". He wants to make the tournament as much big as possible. Thats why he is going to arrange the tournament in a way that maximum number of matches will be played. As we know that a tournament cannot be played for an infinite time so he came up with the following rules:

  • In the first round each of the N team will face every other (N-1) team once. At least one team will be eliminated from the first round according to the point table standings.

  • All other rounds except first round will be played in knockout format. That means in a round each team will play only one match and exactly half of the teams will go to the next round.

Now, the president of LUFA is asking you to write a program to calculate the maximum number of matches possible in the whole tournament for N teams according to the rules mentioned above. Can you do it ?

Input

First line of input takes an integer T: number of testcases
Each of the next T lines takes an integer N: number of teams in the tournament

1 <= \(T\) <= 10^4
1 <= \(N\) <= 10^9

Output

print T lines, each line should contain an integer : The maximum number of matches possible in the tournament for N team.

Sample

Input Output
3
1
3
4
0
4
7

in the first testcase, to its not possible to arrange a match with only one team.

in the second testcase, one team will be eleminated from the first round and remaining two team will play the final. In the first round 3 matches will be played.

in the third testcase, two team will be eleminated from the first round and remaining two will play the final.

Brain booster #2

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
11
Start at
2024-03-06 13:00
End at
2024-03-06 17:00
Duration
4.0 hour(s)
Host
Partic.
49