Kaosar and Minimization#12437

Kaosar and Minimization

2 seconds
256 megabytes
Medium

you are given a integer you have to determine for any two integer what's the minimum value of

|n-x^y|+|x-y|

Here denotes the absolute value of i.e. the magnitude of with neglecting the sign.

Input

The first line contains single integer (1 \le t \le 10^4) — the number of test cases.

The first line of each test case contains single integer (1 \le n \le 10^{18}) — the integer of the problem.

Output

For each test case , Output single integer — The answer to the problem.

Examples

Example 1

Loading
Loading

Scoring

  1. Subtask ( points) : (1 \le \sum n \le 1000)

  2. Subtask ( points) : (1 \le \sum n \le 10^6)

  3. Subtask ( points) : No additional constraints