The ? 1 ? 2 ? ... ? n = k problem
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k:
? 1 ? 2 ? ... ? n = k
For example: to obtain k = 12, the expression to be used will be:
- 1 + 2 + 3 + 4 + 5 + 6 - 7 = 12 with n = 7.
Input
The first line is the number of test cases. Each test case contains integer k (0 ≤ |k| ≤ 10^9
).
Output
For each test case, your program should print the minimal possible n (1 ≤ n) to obtain k with the above formula.
Examples
Input #1
Answer #1
Submissions 417
Acceptance rate 49%