CF2156A.Pizza Time

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Pizza Time

Hao and Alex are good friends. After winning a coding competition together, they received a huge pizza as their prize.

Initially, they are given nn slices of pizza. Each day, the following process takes place:

  • If there are at most 22 slices remaining, Alex eats all of them.

  • Otherwise, let mm be the current number of slices (m3m\ge 3). Hao splits them into three groups of sizes m1m_1, m2m_2, and m3m_3 such that:

    $$m_1 + m_2 + m_3 = m\text{ and } 1 \le m_1\le m_2\le m_3.$$</p><p>Then:</p><ul> <li> Hao eats$m\_1$slices (the smallest group). </li><li> Alex eats$m\_2$slices (the middle group). </li><li> The remaining$m\_3$ slices (the largest group) are carried over to the next day.$$

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first and only line of each test case contains a single integer nn (3n1093 \le n \le 10^9) — the initial number of pizza slices.

Note that there are no constraints on the sum of nn over all test cases.

Output

For each test case, output a single integer representing the maximum total number of slices Hao can eat.

Note

In the first test case, Hao can eat 33 slices as follows:

  1. Split into m1=2m_1 = 2, m2=3m_2 = 3, and m3=3m_3 = 3. Hao eats 22 slices, Alex eats 33 slices, and the remaining 33 slices are carried over to the next day.
  2. Split into m1=1m_1 = 1, m2=1m_2 = 1, and m3=1m_3 = 1. Hao eats 11 slice, Alex eats 11 slice, and the remaining 11 slice is carried over to the next day.
  3. Only 11 slice remains, so Alex eats it.

In the second test case, Hao can eat 11 slice as follows:

  1. Split into m1=1m_1 = 1, m2=1m_2 = 1, and m3=2m_3 = 2. Hao eats 11 slice, Alex eats 11 slice, and the remaining 22 slices are carried over to the next day.
  2. Only 22 slices remain, so Alex eats them all.

Samples

3
8
4
3
3
1
1

在线编程 IDE

建议全屏模式获得最佳体验