Under construction

Still being built. Things may change

Boredom buster (Easy)

Interview

Time limit1sMemory limit1024 MB

Summary
Given n, split each integer by fixed rules and find the maximum total of y*z over all splits until n ones remain.
Level

Easy3 of 10

Topics
Dynamic programming, Recursion
Solved
No attempts yet

Problem

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. Today 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 performing this operation, her brother gives her y⋅zy \cdot z hazelnuts. However, not all pairs of y,zy, z are valid. There are some rules Gillian must comply with. 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 beginning of the game, Gillian starts with a single integer nn. She performs a series of operations described above until she is left with nn copies of the number 1. What is the maximum number of hazelnuts she can win if she chooses her moves wisely?

For any x>1x > 1 there is exactly one valid way of splitting:

  • if xx is divisible by 3, then y=x/3y = x/3 and z=2x/3z = 2x/3;
  • if xx is divisible by 2 (but not by 3), then y=z=x/2y = z = x/2;
  • otherwise, y=1y = 1 and z=x−1z = x - 1.

Input

The first line of the input contains an integer t≤1000t \le 1000 specifying 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≤106n \le 10^6.

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