Under construction

Still being built. Things may change

Boredom Buster (Hard)

Interview

Time limit1sMemory limit1024 MB

Summary
Split an integer into two parts until n ones remain, earning the product of the parts at each split. Find the maximum hazelnuts.
Level

Medium4 of 10

Topics
Math, Combinatorics
Solved
No attempts yet

Statement

Gillian is normally a very lively child. Most of the time she plays with her friends and tries to indulge in some mischief. But today is different. Gillian woke up with the flu, so she has to stay in bed, still and bored. To entertain her, her brother came up with the following game.

When Gillian has an integer xx greater than 1, she can split it into two positive integers yy and zz such that x=y+zx = y + z. After this operation, her brother gives her y⋅zy \cdot z hazelnuts. However, not all pairs of yy and zz are valid. Gillian must follow some rules. These rules differ between the easy and hard subproblems, and they are listed in the problem specification section.

Numbers obtained from this operation can also be split. At the start of the game, Gillian has a single integer nn. She performs a series of operations until she has nn copies of the number 1. What is the maximum number of hazelnuts she can win if she chooses her moves wisely?

Gillian can pick any integer kk with 1<k≤x1 < k \le x and split xx into y=⌊x/k⌋y = \lfloor x/k \rfloor and z=x−⌊x/k⌋z = x - \lfloor x/k \rfloor.

Input

The first line of the input contains an integer tt (t≤1000t \le 1000), the number of test cases. Each test case is preceded by a blank line.

Each test case contains a single line with Gillian's initial integer n>1n > 1. You may assume that n≤109n \le 10^9.

Output

For each test case, output a single line with the maximum number of hazelnuts.

Examples1

  1. Example 1

    Input
    1
    
    5
    
    Expected output
    10