Problems
The ? 1 ? 2 ? ... ? n = k problem
The ? 1 ? 2 ? ... ? n = k problem
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| ≤ 109
).
Output
For each test case, your program should print the minimal possible n (1 ≤ n) to obtain k with the above formula.
Input example #1
2 12 -3646397
Output example #1
7 2701