MINCOUNT - Move To Invert

A triangle made of coins of height h is as follows:

  • It has h coins at the base and h-1 coins one level above base and so on. (Coins are placed as shown in the figure below.)
  • At the top-most level there will be only one coin.

Now given h, the task is to invert this triangle by moving the minimum number of coins.

For example when h=4 triangle is:
Invert

For h=4 at least 3 coins must be moved to invert it.

Input

In the first line N will be given and then N lines follow with each line having a integer which is the height of triangle in that test case. (0 ≤ h < 1010.)

Output

For each test case output in a separate line the minimum number of moves required to invert the triangle. Output fits in long long data type.

Example

Input:
1
3

Output:
2

Added by:Abhilash I
Date:2006-12-16
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO
Resource:IIIT Hyderabad Local Programming Contest

hide comments
2012-05-31 07:59:22 killerz
just a simple math :)
Good prob to show the fastness of printf/scanf over cin/cout
2012-03-23 12:51:04 vD


Last edit: 2012-03-23 12:52:51
2012-02-06 14:30:14 (^@_^@)
uses simple mathematics
but remember to use printf, scanf("%lli").....
and submit with c compiler
2012-02-06 14:29:46 codecracker
it uses very simple mathematics...........
2012-01-08 23:36:57 Albert Chen
Yes... h can be 0.
2011-12-12 14:31:56 MR. BEAN
answer for 100 is 1683 and for 10^10 is 7443294631478557525 !!!
2011-10-05 21:55:49 sri
is the solution for 100 is 1875???
i am not getting 1683.
help me out.
2011-07-22 08:46:37 Pavel Simo
weak test cases accepted with long long...
2011-07-21 21:15:41 Vinay Chaudhary
WTH its not that complicated....analyse the output till 10 you will figure it out..:)..use scanf and printf instead of cin and cout
2011-07-16 10:16:12 The Champ
why ERL is not allowed?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.