The Binary Search Efficiency Doubter

No attempts yetTime limit1sMemory limit256 MB

Problem

Binary search is a classic algorithm in computer science. This problem defines binary search by the following pseudocode.

Search the array a, over a[0] through a[n-1], for the value x.
Assume the values in a are in strictly increasing order.

    Low = 0
    High = n - 1
    While Low <= High
        Mid = (Low + High) / 2   [integer division truncates]
        If a[Mid] = x then return FOUND
        If a[Mid] < x then Low = Mid + 1
        If a[Mid] > x then High = Mid - 1
    If the while loop ends, return NOT_FOUND

Professors teach that the algorithm is efficient, that the loop runs about log2n\log_2 n times in the worst case, and that the average is a little better than that. A student who is not convinced builds lists of several sizes, searches for every value in the list, and counts how many times the loop runs. In the list below, the number of loop iterations spent finding each value is written under that value.

the list12162334425765
loop count3231323

The total loop count for this list is 17.

As long as the list is sorted and all the values are different, every list of length 7 has a total loop count of 17. The length of the list determines the total loop count.

Given the length of the list, compute the total loop count. The answer for every case in the input fits in a signed 64-bit integer.

Input

The input holds several cases. Each case is a single positive integer nn, the length of the list. 2<n<1072 < n < 10^7, and there are at most 100 cases. Any whitespace separates the cases. Read until end of file.

Output

For each case, print the total loop count for finding all the values in a list of length nn. Follow this format exactly: "Case", one space, the case number, a colon, one space, and the answer for that case. Do not print trailing spaces.